Дополнительные действия
Этому шаблону не хватает документации. Вы можете помочь проекту, сделав описание шаблона: что он делает, как его использовать, какие параметры он принимает. Это поможет другим использовать его. Для оформления можете воспользоваться {{doc}} или {{doc-inline}}. Не забывайте помещать описание внутрь <noinclude></noinclude>. P.S. Также не забываем про категорию. |
-- [[Template:Icons]]
local p = {}
local data = mw.loadData('Module:Icons/data')
-- Generates the ending part
function p.main(frame)
local args = frame:getParent().args
local type = mw.ustring.lower(args[2])
local name = mw.ustring.lower(args[1])
local size = args.size or "18"
local typeData
local typeName
if data[type] then
typeData=data[type]
if typeData[name] then
typeName=typeData[name]
if typeName.property then
if typeName.category then
return string.format(
"[[%s|%spx|link=|%s]]",
typeName.image,
size,
typeName.text or ''
)..frame:preprocess("{{#set:"..typeName.property.."="..name.."}}")..frame:preprocess("{{#ifeq:{{NAMESPACE}}||[[Category:"..typeName.category.."]]}}")
else
return string.format(
"[[%s|%spx|link=|%s]]",
typeName.image,
size,
typeName.text or ''
)..frame:preprocess("{{#set:"..typeName.property.."="..name.."}}")
end
else
if typeName.category then
return string.format(
"[[%s|%spx|link=|%s]]",
typeName.image,
size,
typeName.text or ''
)..frame:preprocess("{{#ifeq:{{NAMESPACE}}||[[Category:"..typeName.category.."]]}}")
else
return string.format(
"[[%s|%spx|link=|%s]]",
typeName.image,
size,
typeName.text or ''
)
end
end
end
end
return ""
end
return p