Jump to content

Module:Navbar: Difference between revisions

103 bytes added ,  11 years ago
return error for non-existent page
m>Dragons flight
m (Protected Module:Navbar: Highly visible template: Used on a significant number of pages, but also still in testing. ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
m>Toohool
(return error for non-existent page)
Line 5: Line 5:
function trim(s)
function trim(s)
     return mw.ustring.match( s, "^%s*(.-)%s*$" )
     return mw.ustring.match( s, "^%s*(.-)%s*$" )
end
function error(s)
    local span = HtmlBuilder.create('span')
    span
        .addClass('error')
        .css('float', 'left')
        .css('white-space', 'nowrap')
        .wikitext('Error: ' .. s)
    return tostring(span)
end
end


function _navbar( args )
function _navbar( args )
     if not args[1] then
     if not args[1] then
         local span = HtmlBuilder.create('span')
         return error('No name provided')
        span
            .addClass('error')
            .css('float', 'left')
            .css('white-space', 'nowrap')
            .wikitext('Error: No name provided')
        return span
     end
     end
   
   
Line 26: Line 30:
     else
     else
         title = mw.title.new( pageName, 'Template' );
         title = mw.title.new( pageName, 'Template' );
     end      
     end  
    if not title then
        return error('Page does not exist')
    end
   
   
     local mainpage = title.fullText;
     local mainpage = title.fullText;
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.