Module:RequirementBox: Difference between revisions
Admin Jeremy (talk | contribs) (Created page with "local p = {} function p.render(frame) local title = frame.args.title or "Game" local game = frame.args.game or "" local state = frame.args.state or "" -- Grab content for each category local appear = frame.args.appear or "" local visit = frame.args.visit or "" local resident = frame.args.resident or "" local romance = frame.args.romance or "" local tricks = frame.args.tricks or "" -- Helper to render a category...") |
Admin Jeremy (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
-- Module:RequirementBox | |||
local p = {} | local p = {} | ||
-- Helper: render a category block | |||
local function renderCategory(title, list) | |||
if list == "" then return "" end | |||
return string.format([[ | |||
<div class="vp-requirements-category"> | <div class="vp-requirements-category"> | ||
<div class="requirements-header">%s</div> | <div class="requirements-header">%s</div> | ||
<ul class="vp-requirements-list"> | <ul class="vp-requirements-list"> | ||
%s | |||
</ul> | </ul> | ||
</div> | </div>]], title, list) | ||
]], title, list) | end | ||
function p.render(frame) | |||
local args = frame.args | |||
local title = args.title or "Game" | |||
local game = args.game or "" | |||
local state = args.state or "" | |||
-- Preprocess content to allow full wiki markup | |||
local appear = frame:preprocess(args.appear or "") | |||
local visit = frame:preprocess(args.visit or "") | |||
local resident = frame:preprocess(args.resident or "") | |||
local romance = frame:preprocess(args.romance or "") | |||
local tricks = frame:preprocess(args.tricks or "") | |||
-- Build the requirements HTML | -- Build the requirements HTML | ||
local | local html = renderCategory("Appear", appear) | ||
html = html .. renderCategory("Visit", visit) | |||
html = html .. renderCategory("Resident", resident) | |||
html = html .. renderCategory("Romance", romance) | |||
html = html .. renderCategory("Tricks", tricks) | |||
-- Details open attribute | |||
-- | |||
local openAttr = "" | local openAttr = "" | ||
if state ~= "mw-collapsed | if state ~= "mw-collapsed" then | ||
openAttr = ' open="open"' | openAttr = ' open="open"' | ||
end | end | ||
local | -- Build final <details> box | ||
<details class="vp-gamebox"%s> | local details = string.format([[ | ||
<details class="vp-gamebox"%s data-game="%s"> | |||
<summary class="vp-gamebox-header">%s</summary> | <summary class="vp-gamebox-header">%s</summary> | ||
<div class="vp-gamebox-content"> | <div class="vp-gamebox-content"> | ||
%s | |||
</div> | </div> | ||
</details> | </details>]], openAttr, game, title, html) | ||
]], openAttr, title, | |||
return details | |||
return | |||
end | end | ||
return p | return p | ||
Revision as of 02:45, 3 January 2026
Documentation for this module may be created at Module:RequirementBox/doc
-- Module:RequirementBox
local p = {}
-- Helper: render a category block
local function renderCategory(title, list)
if list == "" then return "" end
return string.format([[
<div class="vp-requirements-category">
<div class="requirements-header">%s</div>
<ul class="vp-requirements-list">
%s
</ul>
</div>]], title, list)
end
function p.render(frame)
local args = frame.args
local title = args.title or "Game"
local game = args.game or ""
local state = args.state or ""
-- Preprocess content to allow full wiki markup
local appear = frame:preprocess(args.appear or "")
local visit = frame:preprocess(args.visit or "")
local resident = frame:preprocess(args.resident or "")
local romance = frame:preprocess(args.romance or "")
local tricks = frame:preprocess(args.tricks or "")
-- Build the requirements HTML
local html = renderCategory("Appear", appear)
html = html .. renderCategory("Visit", visit)
html = html .. renderCategory("Resident", resident)
html = html .. renderCategory("Romance", romance)
html = html .. renderCategory("Tricks", tricks)
-- Details open attribute
local openAttr = ""
if state ~= "mw-collapsed" then
openAttr = ' open="open"'
end
-- Build final <details> box
local details = string.format([[
<details class="vp-gamebox"%s data-game="%s">
<summary class="vp-gamebox-header">%s</summary>
<div class="vp-gamebox-content">
%s
</div>
</details>]], openAttr, game, title, html)
return details
end
return p