Module:Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Replaced content with "---------------------------------------------------------------------------------------------------- -- -- Module:Sandbox -- -- Here you can set anything you want in this sandbox, as long as it uses the language Lua. -- Do not forget to add {{#invoke:Sandbox|<function name>}} in your template. -- Category:Sandbox -- ---------------------------------------------------------------------------------------------------- local p...") Tag: Replaced |
||
Line 6: | Line 6: | ||
-- Do not forget to add {{#invoke:Sandbox|<function name>}} in your template. | -- Do not forget to add {{#invoke:Sandbox|<function name>}} in your template. | ||
-- [[Category:Sandbox]] | -- [[Category:Sandbox]] | ||
-- | |||
---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ||
p = {} | local p = {} | ||
function p. | function p.main(frame) | ||
local args = frame.args | |||
local rows = tonumber(args.rows) or 0 | |||
local cols = tonumber(args.cols) or 0 | |||
local table_class = args.class or "wikitable" | |||
local output = "{| class=\"" .. table_class .. "\"\n" | |||
-- Header row | |||
output = output .. "|-\n" | |||
for j = 1, cols do | |||
output = output .. "! " .. (args["h" .. j] or "") .. "\n" | |||
end | |||
-- Data rows | |||
for i = 1, rows do | |||
output = output .. "|-\n" | |||
for j = 1, cols do | |||
output = output .. "| " .. (args[i .. "_" .. j] or "") .. "\n" | |||
end | |||
end | |||
output = output .. "|}\n" | |||
return output | |||
end | end | ||
return p | return p |
Revision as of 21:50, 24 March 2023
----------------------------------------------------------------------------------------------------
--
-- Module:Sandbox
--
-- Here you can set anything you want in this sandbox, as long as it uses the language Lua.
-- Do not forget to add {{#invoke:Sandbox|<function name>}} in your template.
-- [[Category:Sandbox]]
--
----------------------------------------------------------------------------------------------------
local p = {}
function p.main(frame)
local args = frame.args
local rows = tonumber(args.rows) or 0
local cols = tonumber(args.cols) or 0
local table_class = args.class or "wikitable"
local output = "{| class=\"" .. table_class .. "\"\n"
-- Header row
output = output .. "|-\n"
for j = 1, cols do
output = output .. "! " .. (args["h" .. j] or "") .. "\n"
end
-- Data rows
for i = 1, rows do
output = output .. "|-\n"
for j = 1, cols do
output = output .. "| " .. (args[i .. "_" .. j] or "") .. "\n"
end
end
output = output .. "|}\n"
return output
end
return p