Jump to content

Module:Road data/browsetable

From Calamity Wiki

Lua error in Module:TNT at line 159: Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Uses TemplateStyles.tab.

This module exports the functions browsetable (for use from wikitext) and _browsetable (for use within Lua). The functions can serve as a container for the output of Module:Road data/browse while also adding padding between multiple instances of Module:Road data/browse.

Example

{{Box|width=20em|padding=8px|
{{#invoke:Road data/browsetable|browsetable|
{{oh browse|previous_type=SR|previous_route=222|route=OH|next_type=OH 1927|next_route=223|next_dab=1927-1930}}
{{mi browse|previous_type=M|previous_route=222|route=MI|next_type=M|next_route=227}}
}}
}}
← SR 222OH→ SR 223
← M-222MI→ M-227

local p = {}

function p._browsetable(content, styles)
	if not content then return nil end

	local tbl = mw.html.create('table'):addClass('browse-table')
	tbl:wikitext(content)
	tbl:cssText(styles)

	return mw.getCurrentFrame():extensionTag{
		name = 'templatestyles', args = { src = 'Module:Road data/browsetable/styles.css' }
	} .. tostring(tbl)
end

function p.browsetable(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame)
	return p._browsetable(args[1], args.style)
end

return p