Module:SoftwarePage: Difference between revisions
m Protected "Module:SoftwarePage" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) |
m 1 revision imported |
(No difference)
| |
Latest revision as of 13:21, 6 May 2026
Given printer properties, print out help documentation
local p = {}
local function notEmpty(s)
return s and mw.text.trim(s) ~= ""
end
local function splitList(s)
if not notEmpty(s) then return {} end
local t = {}
for item in mw.text.gsplit(s, ",", true) do
table.insert(t, mw.text.trim(item))
end
return t
end
function p.render(frame)
local args = frame:getParent().args
local rows = {}
-- helper to add a row
local function addRow(label, value)
table.insert(rows, "|-\n| " .. label .. " || " .. value)
end
-- Description
if notEmpty(args.Description) then
addRow("Description", args.Description)
end
-- Access
if notEmpty(args.Access) then
addRow("Access", args.Access)
end
-- Platform (with badges)
if notEmpty(args.Platform) then
local platforms = splitList(args.Platform)
local badges = {}
for _, p in ipairs(platforms) do
table.insert(badges,
'<span class="platform-badge platform-' .. p .. '">' .. p .. '</span>')
end
addRow("Platform", table.concat(badges, " "))
end
-- Location (only if present)
if notEmpty(args.Location) then
addRow("Location", args.Location)
end
-- Accessibility
if args["Supports accessibility"] == "Yes" then
addRow("Supports accessibility", "Yes")
end
-- Build table
local output = '{| class="wikitable"\n! Property !! Value\n'
output = output .. table.concat(rows, "\n") .. "\n|}"
return output
end
return p