Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Navpills: Difference between revisions

From CaelemsWiki
en>Alistair3149
No edit summary
en>Alistair3149
No edit summary
Line 11: Line 11:
if not args then
if not args then
return 'Missing arguments'
return 'Missing arguments'
end
if args then
return mw.dumpObject( args )
end
end


local html = mw.html.create( 'div' ):addClass( 'template-navpills' )
local html = mw.html.create( 'div' ):addClass( 'template-navpills' )
local debug = ''
for i, arg in ipairs( args ) do
for i, arg in ipairs( args ) do
Line 20: Line 23:
local num = tostring( i )
local num = tostring( i )
html:wikitext( string.format( '[[%s|%s]]'), arg[ 'page' .. num ], arg[ 'text' .. num ] )
html:wikitext( string.format( '[[%s|%s]]'), arg[ 'page' .. num ], arg[ 'text' .. num ] )
debug = debug .. arg
end
end
return debug
return mw.getCurrentFrame():extensionTag{
--return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Navpills/styles.css' }
-- name = 'templatestyles', args = { src = 'Module:Navpills/styles.css' }
} .. tostring( html )
--} .. tostring( html )
end
end


return p
return p

Revision as of 06:58, 17 March 2024


local mArguments --initialize lazily
local p = {}

--Implements {{Navpills}} from the frame
function p.navpills( frame )
	mArguments = require( 'Module:Arguments' )
	return p._navpills( mArguments.getArgs( frame ) )
end

function p._navpills( args )
	if not args then
		return 'Missing arguments'
	end
	
	if args then
		return mw.dumpObject( args )
	end

	local html = mw.html.create( 'div' ):addClass( 'template-navpills' )
	
	for i, arg in ipairs( args ) do
		--if not arg[ 'page' .. i ] or not arg[ 'text' .. i ] then return 
		local num = tostring( i )
		html:wikitext( string.format( '[[%s|%s]]'), arg[ 'page' .. num ], arg[ 'text' .. num ] )
	end
	
	return mw.getCurrentFrame():extensionTag{
		name = 'templatestyles', args = { src = 'Module:Navpills/styles.css' }
	} .. tostring( html )
end

return p