From WikiChip
Difference between revisions of "Module:expansions"
(Created page with "local expansion = {} local origArgs function has_arg(name) -- The argument can exist and be empty or not exist at all return string.len(origArgs[name] or '') > 0 end funct...") |
|||
Line 44: | Line 44: | ||
return box | return box | ||
end | end | ||
+ | |||
+ | return expansion |
Revision as of 19:46, 16 August 2017
Documentation for this module may be created at Module:expansions/doc
local expansion = {}
local origArgs
function has_arg(name)
-- The argument can exist and be empty or not exist at all
return string.len(origArgs[name] or '') > 0
end
function arg(name)
return origArgs[name]
end
function single_entry(box, argn)
if has_arg(argn) then
box:tag('div'):attr('style', 'min-width: 250px; display: inline-block;'):wikitext("'''" .. argn .. ":''' " .. arg(argn))
end
end
function expansion.expansion(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
local entry = mw.html.create('div')
entry
:attr('style', 'background:#f9f9f9; margin: 10px 2px 10px 2px; padding: 5px; border: 1px solid #a7d7f9;')
if not has_arg('type') then
return "* ERROR: '''WRONG <code>type</code> parameter!'''"
end
if arg('type') == 'PCIe' then
return expansion.pcie(entry)
end
return entry
end
function expansion.pcie(box)
return box
end
return expansion