Module:History: Difference between revisions

From Vintage Story Wiki
mNo edit summary
mNo edit summary
Line 4: Line 4:
local args = require( 'Module:ProcessArgs' ).merge( true )
local args = require( 'Module:ProcessArgs' ).merge( true )
local header = '{| class="wikitable"!colspan="3"|History|-'
local header = {
'{|class="wikitable"',
'!colspan="3"|History',
'|-'
}
if args.header then
if args.header then
return header
return table.concat(header, '\n')
end
end
Line 19: Line 23:
local childVer = args[2]
local childVer = args[2]
local child = '||[[' .. childVer .. ']]'
local child = '[[' .. childVer .. ']]'
local notes = '||' .. args[3]
local parent
local parent
local body
local body
if parentVer then
if parentVer then
parent = '|[[' .. parentVer .. ']]'
parent = '[[' .. parentVer .. ']]'
body =  parent .. child .. notes
body =  {
'|' .. parent .. '||' .. child .. '||' .. args[3]
}
else
else
body = '|' .. child .. notes
body = '|' .. child .. notes

Revision as of 16:26, 20 August 2022

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

local p = {}

function p.create(f)
	local args = require( 'Module:ProcessArgs' ).merge( true )
		
	local header = {
		'{|class="wikitable"',
		'!colspan="3"|History',
		'|-'
	}
		
	if args.header then
		return table.concat(header, '\n')
	end
	
	local footer = '|}'
	
	if args.footer then
		return footer
	end
	
	local parentVer = args[1] or ''
	local childVer = args[2]
	
	local child = '[[' .. childVer .. ']]'
	
	local parent
	local body
	if parentVer then
		parent = '[[' .. parentVer .. ']]'
		body =  {
			'|' .. parent .. '||' .. child .. '||' .. args[3]
			}
	else
		body = '|' .. child .. notes
	end
	
	return body
end
return p