[dismiss]
The wiki is currently a work in progress. If you'd like to help out, please check the Community Portal and our getting started guide. Also, check out our sister project on poewiki.net.
Module:Anchor: Difference between revisions
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...") |
mNo edit summary |
||
Line 15: | Line 15: | ||
function p._main(args) | function p._main(args) | ||
args = args or {} | args = args or {} | ||
local | local anchors = {} | ||
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( | table.insert(anchors, '<span id="' .. mw.text.trim(v) .. '"></span>') | ||
end | end | ||
end | end | ||
return table.concat( | return table.concat(anchors) | ||
end | end | ||
return p | return p |
Revision as of 02:27, 27 July 2014
The above documentation is transcluded from Module:Anchor/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
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', -- Wrappers invokes frame:title()
trim = false
})
return p._main(args)
end
function p._main(args)
args = args or {}
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