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 tostring( 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 23: Line 20:
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 mw.getCurrentFrame():extensionTag{
return debug
name = 'templatestyles', args = { src = 'Module:Navpills/styles.css' }
--return mw.getCurrentFrame():extensionTag{
} .. tostring( html )
-- name = 'templatestyles', args = { src = 'Module:Navpills/styles.css' }
--} .. tostring( html )
end
end


return p
return p

Revision as of 06:57, 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

	local html = mw.html.create( 'div' ):addClass( 'template-navpills' )
	local debug = ''
	
	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 ] )
		debug = debug .. arg
	end
	
	return debug
	--return mw.getCurrentFrame():extensionTag{
	--	name = 'templatestyles', args = { src = 'Module:Navpills/styles.css' }
	--} .. tostring( html )
end

return p