Module:Anchor: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
(Created page with "local p = {} local getArgs function p.main(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end local args = getArgs(frame, { -- wrappers = 'Te...")
 
>Vinifera7
(The wrappers feature of getArgs can now be used)
 
(2 intermediate revisions by one other user not shown)
Line 7: Line 7:
end
end
local args = getArgs(frame, {
local args = getArgs(frame, {
-- wrappers = 'Template:Anchor', -- Wrappers invokes frame:title()
wrappers = 'Template:Anchor',
trim = false
trim = false
})
})
Line 14: Line 14:


function p._main(args)
function p._main(args)
args = args or {}
local anchors = {}
local iargs = {}
for k, v in pairs(args) do
for k, v in pairs(args) do
if type(k) == 'number' and k >= 1 and math.floor(k) == k and string.find(v, '%S') then
if type(k) == 'number' and k >= 1 and math.floor(k) == k and string.find(v, '%S') then
table.insert(iargs, '<span id="' .. mw.text.trim(v) .. '"></span>')
table.insert(anchors, '<span id="' .. mw.text.trim(v) .. '"></span>')
end
end
end
end
return table.concat(iargs)
return table.concat(anchors)
end
end


return p
return p

Latest revision as of 02:24, 8 November 2014

Module documentation[view] [edit] [history] [purge]


Lua logo

This module depends on the following other modules:

Implements {{Anchor}}.

local p = {}
local getArgs

function p.main(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	local args = getArgs(frame, {
		wrappers = 'Template:Anchor',
		trim = false
	})
	return p._main(args)
end

function p._main(args)
	local anchors = {}
	for k, v in pairs(args) do
		if type(k) == 'number' and k >= 1 and math.floor(k) == k and string.find(v, '%S') then
			table.insert(anchors, '<span id="' .. mw.text.trim(v) .. '"></span>')
		end
	end
	return table.concat(anchors)
end

return p