Дополнительные действия
Этому шаблону не хватает документации. Вы можете помочь проекту, сделав описание шаблона: что он делает, как его использовать, какие параметры он принимает. Это поможет другим использовать его. Для оформления можете воспользоваться {{doc}} или {{doc-inline}}. Не забывайте помещать описание внутрь <noinclude></noinclude>. P.S. Также не забываем про категорию. |
local p = {}
-- Credit: Layton Wikia
function p.tlx( frame )
local a = frame:getParent().args
local page = a[1]
if not page then return '' end
local prefix = a.prefix and a.prefix .. ':' or ''
local ns = 'Template:' --Default
-- Check Namespace
if a.prefix == '#invoke' then ns = 'Module:'
elseif a.subst == 'true' then prefix = 'subst:'
else
local pageNs = page:match('^(.-):')
if pageNs and ( pageNs == '' or mw.site.namespaces[pageNs] ) then
ns = ''
end
end
-- Build Output
local out = { '{{',prefix,'[[',ns,page,'|',page,']]' }
local i = 2
while a[i] ~= nil do
local arg = a[i]
if arg then
local f = arg:find('=')
if f then
out[#out+1] = '|' .. arg:sub(0,f) .. '<span style="color:#999;"><' .. arg:sub(f+1) .. '></span>'
else
out[#out+1] = '|<span style="color:#999;"><' .. arg .. '></span>'
end
end
i = i + 1
end
out[#out+1] = '}}'
if a.style == 'code' then
out[1] = '<code>{{'
out[#out+1] = '</code>'
end
return table.concat(out)
end
return p
--[[Category:Lua Modules]]