Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Cards

From the Star Citizen Wiki, the fidelity™ encyclopedia
Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Cards/doc. Changes can be proposed in the talk page.
Function list
L 7 — p.cards
L 12 — p._cards

local mArguments --initialize lazily
local getArgNums = require('Module:Common').getArgNums
local p = {}


--Implements {{cards}} from the frame
function p.cards(frame)
	mArguments = require('Module:Arguments')
	return p._cards(mArguments.getArgs(frame), frame)
end

function p._cards(args, frame)
	if not args then
		return 'Missing arguments'
	end

	local html = mw.html.create('div'):addClass('template-cards')
	local columns = 0

	for i, _ in ipairs(getArgNums('content', args)) do
		local num = tostring(i)
		local content = args['content' .. num]
		if not content then return end

		local card = mw.html.create('div'):addClass('template-card')

		local column = args['column' .. num]
		if column then
			card:addClass('template-card--col-' .. column)
			columns = columns + tonumber(column)
		else
			columns = columns + 1
		end

		local header = args['header' .. num]
		if header then
			card:tag('div'):addClass('template-card-header')
				:wikitext(header)
				:done()
		end

		card:tag('div'):addClass('template-card-content')
			:wikitext(content)
			:done()

		html:node(card)
	end

	html:css('grid-template-columns', string.format('repeat(%d, minmax(0, 1fr))', columns))

	return frame:extensionTag {
		name = 'templatestyles', args = { src = 'Module:Cards/styles.css' }
	} .. tostring(html)
end

return p
Heya! We only use cookie to make the site function and save your preferences, nothing else :)