Module:Infobox/Widget/Row: Difference between revisions

From TwogPedia
No edit summary
mNo edit summary
Line 1: Line 1:
local Row = {}
local Row = {}


function Row.make(rowName, value, link)
function Row.make(rowName, value, link, prefix)
local container = mw.html.create('div')
local container = mw.html.create('div')
:addClass('ib-row')
:addClass('ib-row')
Line 15: Line 15:


if link ~= nil then
if link ~= nil then
valueNode:wikitext('[[' .. value .. ']]')
valueNode:wikitext('[[' .. prefix or '' .. value .. '|' .. value .. ']]')
else  
else  
valueNode:wikitext(value)
valueNode:wikitext(value)

Revision as of 19:09, 3 June 2023

Documentation for this module may be created at Module:Infobox/Widget/Row/doc

local Row = {}

function Row.make(rowName, value, link, prefix)
	local container = mw.html.create('div')
		:addClass('ib-row')
	local name = mw.html.create('div')
			:addClass('ib-rowName')
			:wikitext(rowName .. ': ')
	local valueNode = mw.html.create('div')
	
	-- If value is table
	if type(value) ~= 'string' then
		return container:node(name):node(value)
	end

	if link ~= nil then
		valueNode:wikitext('[[' .. prefix or '' .. value .. '|' .. value .. ']]')
	else 
		valueNode:wikitext(value)
	end
	
	return container:node(name):node(valueNode)
end


return Row