Module:template: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
(Created page with "local export = {} function export.show(frame) frame = frame:getParent() or frame local out = {"{{", frame.args[1]} local i = 2 while frame.args[i] do table.insert(out, "|" .. frame.args[i]) i = i + 1 end for key, value in ipairs(frame.args) do if type(key) == "string" then table.insert(out, "|" .. key .. "=" .. value) end end table.insert("}}") return table.concat(out) end return export")
 
No edit summary
Line 1: Line 1:
local export = {}
local export = {}


function export.show(frame)
local function make_template(frame, nested)
frame = frame:getParent() or frame
local args = (frame:getParent() and frame:getParent().args) or frame.args
local out = {"{{", frame.args[1]}
local out = {"&#123;&#123;", (nested and "<code>") or "", frame.args[1]}
local i = 2
local i = 2
while frame.args[i] do
while frame.args[i] do
Line 14: Line 14:
end
end
end
end
table.insert("&#125;&#125;")
table.insert((nested and "") or "</code>", "&#125;&#125;")
return table.concat(out)
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
end


return export
return export