Module:Ruler

From The Kingkiller Chronicle Wiki
Revision as of 22:01, 15 December 2018 by Corey (talk | contribs) (Try to unlink {{{ruler}}})
Jump to navigation Jump to search

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

-- <nowiki>
local p = {}

function p.ruler(frame)
    local lines = mw.text.split(frame.args[1], '*')
    local result = ''
    for k, v in ipairs(lines) do
        v = mw.text.trim(v)
        if v ~= '' then
            result = result .. '[[Category:Locations ruled by ' .. v .. ']]'
        end
    end
    return result
end

function p.unlink( frame )
    local args = frame:getParent().args
    return args[1] and ( args[1]:match( '%[%[:?(.-)[|%]]' ) or text.trim( args[1] ) )
end

return p
-- </nowiki>