Module:Succession table monarch

local getArgs = require('Module:Arguments').getArgs
local TableTools = require('Module:TableTools')
local messages = mw.loadData('Module:Succession table monarch/messages')

local p = {}

p.fromArgs = function(argElements)
	local mainTag = mw.html.create('table')
		:addClass('succession-table-monarch wikitable')
		:css('text-align', 'center')
		:tag('tr')
			:tag('th'):wikitext(messages.name):done()
			:tag('th'):wikitext(messages.lifespan):done()
			:tag('th'):wikitext(messages.reignStart):done()
			:tag('th'):wikitext(messages.reignEnd):done()
			:tag('th'):wikitext(messages.notes):done()
			:tag('th'):wikitext(messages.family):done()
			:tag('th'):wikitext(messages.image):done()
			:done()
	
	local ubl = require('Module:List').unbulleted
	for _,eachElement in ipairs(argElements) do
		if eachElement.name then
			local list_args = {
				list_style = 'text-align: center'
			}
			if eachElement.nickname then
				table.insert(list_args, tostring(mw.html.create('small'):tag('i'):wikitext(eachElement.nickname)))
			end
			if eachElement.native then 
				table.insert(list_args, eachElement.native)
			end
			local rowTr = mainTag:tag('tr')
			
			rowTr:tag('td')
					:css('vertical-align: middle;')
					:wikitext(eachElement.name .. ubl(list_args))
					:done()
				:tag('td')
					:wikitext(eachElement.life)
				:tag('td')
					:wikitext(eachElement.reignstart)
				:tag('td')
					:wikitext(eachElement.reignend)
				:tag('td')
					:wikitext(eachElement.notes)
				:tag('td')
					:wikitext(eachElement.family)
			
			local imageTd = rowTr
				:tag('td')
			if eachElement.image then
				imageTd:tag('span')
					:addClass('photo')
					:wikitext('[[File:' .. eachElement.image .. '|80px|alt=' .. (eachElement.alt or '') .. ']]')
			end
		end
	end
	return tostring(mainTag)
end

p.fromArray = function(args)
	local argElements = TableTools.numData(args, true)
	return p.fromArgs(argElements)
end

p.fromFrame = function(frame)
	local args = getArgs(frame)
	return p.fromArray(args)
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.