Module:template: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
local function make_template(frame, nested) | local function make_template(frame, nested) | ||
local args = (frame:getParent() and frame:getParent().args) or frame.args | local args = (frame:getParent() and frame:getParent().args) or frame.args | ||
local out = {"{{", (nested and " | local out = {"{{", (nested and "") or "<code>", args[1]} | ||
local i = 2 | local i = 2 | ||
while args[i] do | while args[i] do |
Revision as of 18:16, 5 August 2023
Documentation for this module may be created at Module:template/documentation
local export = {}
local function make_template(frame, nested)
local args = (frame:getParent() and frame:getParent().args) or frame.args
local out = {"{{", (nested and "") or "<code>", args[1]}
local i = 2
while args[i] do
table.insert(out, "|" .. args[i])
i = i + 1
end
for key, value in ipairs(args) do
if type(key) == "string" then
table.insert(out, "|" .. key .. "=" .. value)
end
end
table.insert(out, ((nested and "") or "</code>") .. "}}")
return table.concat(out)
end
function export.show(frame)
return make_template(frame, false)
end
function export.showNested(frame)
return make_template(frame, true)
end
return export