Module:Details: Difference between revisions
From Shroudforge
More actions
starcitizen>Alistair3149 Sync from Git (via update-page on MediaWiki MCP Server) |
Bonsaibauer (talk | contribs) m 1 revision imported: Import Star Citizen Modules |
(No difference)
| |
Latest revision as of 22:22, 4 November 2026
Documentation for this module may be created at Module:Details/doc
require('strict')
local p = {}
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg
--- @class DetailsData
--- @field summary DetailsSummaryData The summary of the details.
--- @field details DetailsDetailsData The details of the details.
--- @class DetailsSummaryData
--- @field content string The content of the summary.
--- @field class string|nil An additional HTML class for the summary. Optional.
--- @class DetailsDetailsData
--- @field content string The content of the details.
--- @field class string|nil An additional HTML class for the details. Optional.
--- @field open boolean|nil Whether the details are open by default. Defaults to true.
--- Get the wikitext for the details element
---
--- @param data DetailsData
--- @param frame mw.frame|nil The frame object to use. Defaults to the current frame.
--- @return string
function p.getWikitext(data, frame)
frame = frame or mw.getCurrentFrame()
checkType('Module:Details.getWikitext', 1, data, 'table')
checkTypeForNamedArg('Module:Details.getWikitext', 'summary', data.summary, 'table')
checkTypeForNamedArg('Module:Details.getWikitext', 'details', data.details, 'table')
checkType('Module:Details.getWikitext', 2, frame, 'table')
local summary = frame:extensionTag({
name = 'summary',
content = data.summary.content,
args = {
class = data.summary.class,
},
})
local details = frame:extensionTag({
name = 'details',
content = summary .. data.details.content,
args = {
class = data.details.class,
-- Boolean does not work with Extension:Details, has to be 'yes' or 'no'
open = data.details.open ~= false and 'yes' or 'no',
},
})
return details
end
return p