Naruto Fanfiction Wiki
Advertisement

Documentation for this module may be created at Module:Tlx/doc

local p = {}

-- Credit: Layton Wikia
function p.tlx( frame )
	local a = frame:getParent().args
	local page = a[1]
	if not page then return '' end

	local prefix = a.prefix and a.prefix .. ':' or ''
	local ns = 'Template:' --Default

	-- Check Namespace
	if a.prefix == '#invoke' then ns = 'Module:'
	elseif a.subst == 'true' then prefix = 'subst:'
	else
		local pageNs = page:match('^(.-):')
		if pageNs and ( pageNs == '' or mw.site.namespaces[pageNs] ) then
			ns = ''
		end
	end

	-- Build Output
	local out = { '{{',prefix,'[[',ns,page,'|',page,']]' }
 
	local i = 2
	while a[i] ~= nil do
		local arg = a[i]
		if arg then
			local f = arg:find('=')
			if f then
				out[#out+1] = '|' .. arg:sub(0,f) .. '<span style="color:#999;">&lt;' .. arg:sub(f+1) .. '&gt;</span>'
			else
				out[#out+1] = '|<span style="color:#999;">&lt;' .. arg .. '&gt;</span>'
			end
		end
		i = i + 1
	end

	out[#out+1] = '}}'

	if a.style == 'code' then
		out[1] = '<code>{{'
		out[#out+1] = '</code>'
	end

	return table.concat(out)
end

return p
--[[Category:Lua Modules]]
Advertisement