Jump to content
Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.

Die Dokumentation für dieses Modul kann unter Modul:Details/doc erstellt werden

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
Zuletzt geändert
Urheberrecht
Cookies helfen uns bei der Bereitstellung dieses Wikis. Durch die Nutzung des Star Citizen Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.