Module:Navbar: Difference between revisions

    m>Edokter
    (No longer needed; moved fix to Common.css.)
    m>Jackmcbarn
    (remove obnoxious pcall-and-rethrow behavior, now that real script errors include details)
    Line 6: Line 6:
    local function trim(s)
    local function trim(s)
    return mw.ustring.match(s, "^%s*(.-)%s*$")
    return mw.ustring.match(s, "^%s*(.-)%s*$")
    end
    local function htmlError(s)
    local span = HtmlBuilder.create('span')
    span
    .addClass('error')
    .css('float', 'left')
    .css('white-space', 'nowrap')
    .wikitext('Error: ' .. s)
    return tostring(span)
    end
    end


    Line 40: Line 28:


    function p._navbar(args)
    function p._navbar(args)
    local good, title, talk_title;
    local title, talk_title;
    local titleArg = 1
    local titleArg = 1
    Line 54: Line 42:
    end
    end
    good, title, talk_title = pcall(getTitle, args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle()));
    title, talk_title = getTitle(args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle()));
    if not good then
    return htmlError(title);
    end


    if not title then
    if not title then
    return htmlError('Page does not exist')
    error('Page does not exist')
    end
    end