Jump to content

Module:Location

From Creopedia

This documentation is transcluded from Module:Location/doc.

A meta module for all Location-related templates.

Page Description
Module:Location/Components/Infobox Renders the infobox
Module:Location/Components/Table Renders Template:Locations
Module:Location/Components/GameTabsTable Renders Template:GameTabsLocations
Module:Location/styles.css Override styles for the included templates

require( 'strict' )

local p = {}

local templateArgs = {}

--- Wikitext entry point for the module
---
--- @param frame mw.frame
--- @return string
function p.main( frame )
	local getArgs = require( 'Module:Arguments' ).getArgs
	return p._main( getArgs( frame ) )
end

--- Lua entry point for the module
---
--- @param args table
--- @return string
function p._main( args )
	args = args or {}

	templateArgs = args

	local wikitext = {
		p.renderInfobox(),
		p.renderCategories( p.getCategories() )
	}

	return table.concat( wikitext )
end

--- Return the wikitext for the infobox
---
--- @return string
function p.renderInfobox()
	local infobox = require( 'Module:Location/Components/Infobox' )
	local styles = mw.getCurrentFrame():extensionTag {
		name = 'templatestyles', args = { src = 'Module:Location/styles.css' }
	}
	return styles .. infobox.render( {
		args = templateArgs
	} )
end

--- Get the page categories
---
--- @return table
function p.getCategories()
	local categories = {
		'Locations',
		'Locations in EvoCreo2'
	}
	return categories
end

--- Return the wikitext for the category
---
--- @param categories table
--- @return string
function p.renderCategories( categories )
	local wikitext = {}

	for _, category in ipairs( categories ) do
		table.insert( wikitext, string.format( '[[Category:%s]]', category ) )
	end

	return table.concat( wikitext, '' )
end

return p