Modul:Tabbox

Aus FürthWiki
local p = {} --p stands for package

function p.Faktenbox( frame )
	local args = frame:getParent().args
	
	-- Before you ask: No, you cant' use extensionTag here!
	local tpl_bild = p.bild(frame, args)
	local tab_bild=''
	if tpl_bild:gsub("%s+", "") ~= '' then
		tab_bild='<tab name=Bild>' .. 
		tpl_bild .. '</tab>'
	end
	
	local tpl_karte = p.karte(frame, args)
	local tab_karte=''
	if tpl_karte:gsub("%s+", "") ~= '' then
		tab_karte='<tab name=Karte>' .. 
		tpl_karte .. '</tab>'
	end

	local tab_tab=''
	if args[2] ~= nil then
		local tpl_tab = p.tab(frame, args[2])
		if tpl_tab:gsub("%s+", "") ~= '' then
			tab_tab='<tab name=' .. args[1] .. '>' .. tpl_tab .. '</tab>'
		end
	end

	local t ='<div class=factbox><tabs>' .. 
	   tab_bild .. 
	   tab_karte ..
	   tab_tab .. 
	   '</tabs></div>'

	-- Use preprocess to render the factbox and all contens at once
	return frame:preprocess(t)
end

function p.bild(frame, args)
    return frame:expandTemplate{title = 'Bildertab', args={Bild=args.Bild}}
end

function p.karte(frame, args)
    return frame:expandTemplate{title = 'Faktenbox/Karte', args=args}
end

function p.tab(frame, tabcontent)
    return frame:expandTemplate{title = 'Faktenbox/Tab', args={tabcontent=tabcontent}}
end

return p