Jump to content

Module:Navboxes: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Lua version of template:Navboxes
 
No edit summary
Line 12: Line 12:
local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain'
local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain'
local title = args['title'] or 'Links to related articles'
local title = args['title'] or 'Links to related articles'
local list = args['list1'] or args['list'] or ''
local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';'
local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';'
.. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '')
.. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '')
Line 18: Line 19:
return Navbox._navbox({
return Navbox._navbox({
navbar = navbar, title = title,
navbar = navbar, title = title,
list1 = args['list1'] or args['list'] or '',
list1 = list,
state = args['state'] or 'collapsed',
state = args['state'] or 'collapsed',
titlestyle = titlestyle,
titlestyle = titlestyle,
Line 24: Line 25:
listpadding = '0px',
listpadding = '0px',
tracking = 'no'
tracking = 'no'
}) .. (isnotempty(args['list1'] or args['list'] or '') and '' or '[[Category:Navboxes template with no content]]')
}) .. ( (list == '') and '[[Category:Navboxes template with no content]]' or '')


end
end

Revision as of 20:15, 5 February 2016

-- This implements Template:navboxes
local p = {}

local Navbox = require('Module:Navbox')

local function isnotempty(s)
	return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end

function p.navbox(frame)
	local args = frame:getParent().args
	local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain'
	local title = args['title'] or 'Links to related articles'
	local list = args['list1'] or args['list'] or ''
	local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';'
		.. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '')
		.. (isnotempty(args['bordercolor']) and ('border: 1px solid ' .. args['bordercolor'] .. ';') or '')
		.. (args['titlestyle'] or '')
	return Navbox._navbox({
			navbar = navbar, title = title, 
			list1 = list,
			state = args['state'] or 'collapsed',
			titlestyle = titlestyle,
			liststyle = 'font-size:114%',
			listpadding = '0px',
			tracking = 'no'
			}) .. ( (list == '') and '[[Category:Navboxes template with no content]]' or '')

end

return p