My Little Pony Friendship is Magic Wiki
Register
(I think this is all I need to do here)
mNo edit summary
Line 24: Line 24:
 
convert({tp, r='oa', PonyLife=args.PonyLife}) + offset,
 
convert({tp, r='oa', PonyLife=args.PonyLife}) + offset,
 
PonyLife=args.PonyLife,
 
PonyLife=args.PonyLife,
getmisc=args.getmisc
+
getmisc=args.ismisc
 
})
 
})
 
if title == 'N/A' or title == 'TBA' or mw.ustring.find(title, 'class="error"', 1, true) then
 
if title == 'N/A' or title == 'TBA' or mw.ustring.find(title, 'class="error"', 1, true) then

Revision as of 17:48, 22 June 2020

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

--Please see [[Template:Episode]] for documentation. Do not use #invoke directly.
--Template must pass calculated #titleparts call as named param "tp".
local p = {}
local convert = require('Module:Nameconvert').call

function p.main(frame)
    return p.call(frame:getParent().args, frame.args.tp)
end

function p.call(args, tp)
    if not tp then
        return '<span class="error">missing title part</span>'
    end
    local prefix = args.pre or ''
    local suffix = args.suf or ''
    local linkText = args[3] or mw.ustring.gsub(prefix .. suffix, '/', '')
    local offset = 0
    if args[2] == 'prev' then
        offset = -1
    elseif args[2] == 'next' then
        offset = 1
    end
    local title = convert({
        convert({tp, r='oa', PonyLife=args.PonyLife}) + offset,
        PonyLife=args.PonyLife,
        getmisc=args.ismisc
    })
    if title == 'N/A' or title == 'TBA' or mw.ustring.find(title, 'class="error"', 1, true) then
        return title
    end
    if linkText == 'TITLE' then
        linkText = title
    end
    local link = prefix .. title .. suffix
    if linkText == '' then
        return '[' .. '[' .. link .. ']]'
    else
        return '[' .. '[' .. link .. '|' .. linkText .. ']]'
    end
end

return p