मॉड्यूल:Flag/sandbox
"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:Flag/sandbox/doc पर बनाया जा सकता है"
-- This module implements [[साँचा:Flag]].
local data = mw.loadData('Module:Flag/data/sandbox')
local p = {}
function p._main(args)
local code = args.class or args[1]
local iconOnly = args.class or args[2]
local flagData
local flagOutput
if code then
code = code:match('^%s*(.-)%s*$') -- trim whitespace
flagData = data[code]
end
if not flagData then
flagData = data._DEFAULT
end
if not iconOnly then -- evaluate if only icon to be shown or with name; default is with name
flagOutput = string.format(
'<span class="flagicon">[[File:%s|16x16px|link=]] </span>%s', flagData.image, flagData.name -- with name
)
else
flagOutput = string.format(
'<span class="flagicon">[[File:%s|16x16px|%s|link=]]</span>', flagData.image, flagData.name -- only icon and no name
)
end
return flagOutput
end
function p.main(frame)
local args = {}
for k, v in pairs(frame:getParent().args) do
args[k] = v
end
return p._main(args)
end
return p