Module:InfoboxPlanet: Difference between revisions
Created page with "local p = {} function p.main(frame) local args = frame.args local rows = {} local function row(label, value) if value and value ~= "" then table.insert(rows, string.format("|-\n! %s\n| %s", label, value) ) end end row("Galaxy", args.galaxy) row("Radius", args.radius) row("Location", args.location) row("Stargate", args.stargate) local image = "" if args.image then i..." |
No edit summary |
||
| Line 19: | Line 19: | ||
local image = "" | local image = "" | ||
if args.image then | if args.image and args.image ~= "" then | ||
image = string.format( | image = string.format( | ||
"|-\n| colspan=\"2\" class=\"infobox-image\" | [[File:%s|250px]]", | "|-\n| colspan=\"2\" class=\"infobox-image\" | [[File:%s|250px]]", | ||
| Line 26: | Line 26: | ||
end | end | ||
local wikitext = string.format([[ | |||
{| class="infobox" | {| class="infobox" | ||
%s | %s | ||
| Line 34: | Line 34: | ||
|} | |} | ||
]], image, args.name or frame:getTitle(), table.concat(rows, "\n")) | ]], image, args.name or frame:getTitle(), table.concat(rows, "\n")) | ||
-- THIS is the missing step | |||
return frame:preprocess(wikitext) | |||
end | end | ||
return p | return p | ||
Latest revision as of 03:12, 29 December 2025
Documentation for this module may be created at Module:InfoboxPlanet/doc
local p = {}
function p.main(frame)
local args = frame.args
local rows = {}
local function row(label, value)
if value and value ~= "" then
table.insert(rows,
string.format("|-\n! %s\n| %s", label, value)
)
end
end
row("Galaxy", args.galaxy)
row("Radius", args.radius)
row("Location", args.location)
row("Stargate", args.stargate)
local image = ""
if args.image and args.image ~= "" then
image = string.format(
"|-\n| colspan=\"2\" class=\"infobox-image\" | [[File:%s|250px]]",
args.image
)
end
local wikitext = string.format([[
{| class="infobox"
%s
|-
| colspan="2" class="infobox-title" | %s
%s
|}
]], image, args.name or frame:getTitle(), table.concat(rows, "\n"))
-- THIS is the missing step
return frame:preprocess(wikitext)
end
return p