PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Clan: Difference between revisions

From PC Gaming Shelter
Created page with "local utils = require( 'Module:Utils' ) local p = {} local function propertiesPlan() -- ['Form field name'] = { 'Semantic property', 'delimiter' } local propMap = { ['Member of'] = {'Member of' }, ['Has role'] = {'Has role', ',' }, ['Has note'] = {'Has note' } } return propMap end function p.main(frame) local args = frame:getParent().args local propMap = propertiesPlan() local props = utils.setProperties(propMap, args) or {..."
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 20: Line 20:
local community = args['Member of'] or nil
local community = args['Member of'] or nil
local roles = args['Has role'] or nil
local html = mw.html.create()
local html = mw.html.create()


Line 28: Line 28:
}
}
mw.smw.set(escalateLink)
mw.smw.set(escalateLink)
local roles = args['Has role'] or nil
if roles then
roles = string.format(' (%s)', roles )
else
roles = ''
end
html:tag('span'):wikitext(string.format('[[%s]]', community))
local note = args['Has note'] or nil
if note then
note = frame:callParserFunction(
'#info', note
)
else
note = ''
end
if roles then
html:tag('div'):wikitext(string.format('[[%s]]', community))
html:tag('span'):wikitext(string.format('(%s)', roles ))
html:tag('div'):wikitext(string.format('<span class="text-secondary small">%s</span> %s', roles, note))
end
end
end

Latest revision as of 18:24, 25 March 2026

Documentation for this module may be created at Module:Clan/doc

local utils = require( 'Module:Utils' )

local p = {}

local function propertiesPlan()
	-- ['Form field name'] = { 'Semantic property', 'delimiter' }
	local propMap = {
		['Member of']           = {'Member of' },
		['Has role']            = {'Has role', ',' },
		['Has note']            = {'Has note' }
	}
	return propMap
end

function p.main(frame)
	local args = frame:getParent().args
	local propMap = propertiesPlan()
	local props = utils.setProperties(propMap, args) or {}
	mw.smw.subobject(props)
	
	local community = args['Member of'] or nil
	
	local html = mw.html.create()

	if community then 
		local escalateLink = {
			['Member of'] = args['Member of']
		}
		mw.smw.set(escalateLink)
	
		local roles = args['Has role'] or nil
		if roles then
			roles = string.format(' (%s)', roles )
		else
			roles = ''
		end	
		
		local note = args['Has note'] or nil
		if note then
			note = frame:callParserFunction(
				'#info', note
			)
		else
			note = ''
		end
		
		html:tag('div'):wikitext(string.format('[[%s]]', community))
		html:tag('div'):wikitext(string.format('<span class="text-secondary small">%s</span> %s', roles, note))
	end
	
	return html
end

return p