Module:Navbar: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
m (Changed protection level of Module:Navbar: Highly visible template or Lua module ([Edit=Block all non-admin users] (indefinite) [Move=Block all non-admin users] (indefinite)))
(handle expensive parser function limit without killing the box)
Line 17: Line 17:


return tostring(span)
return tostring(span)
end

function getTitle( pageName )
pageName = trim( pageName );
if mw.ustring.sub(pageName, 1, 1) == ':' then
return mw.title.new( mw.ustring.sub(pageName, 2) );
else
return mw.title.new( pageName, 'Template' );
end
end
end


Line 24: Line 33:
end
end
local title;
local good, title;
local pageName = trim(args[1])
good, title = pcall( getTitle, args[1] );
if mw.ustring.sub(pageName, 1, 1) == ':' then
if not good then
return error('Expensive parser function limit exceeded');
title = mw.title.new( mw.ustring.sub(pageName, 2) );
else
end

title = mw.title.new( pageName, 'Template' );
end
if not title then
if not title then
return error('Page does not exist')
return error('Page does not exist')