Module:Navbar/sandbox: Difference between revisions

Content deleted Content added
use mw.html
Jackmcbarn (talk | contribs)
sync changes from live, keeping mw.html support
Line 5:
local function trim(s)
return mw.ustring.match(s, "^%s*(.-)%s*$")
end
 
local function htmlError(s)
local span = mw.html.create('span')
 
span
:addClass('error')
:css('float', 'left')
:css('white-space', 'nowrap')
:wikitext('Error: ' .. s)
 
return tostring(span)
end
 
Line 39 ⟶ 27:
 
function p._navbar(args)
local good, title, talk_title;
local titleArg = 1
Line 53 ⟶ 41:
end
good,local title, talk_titletitleText = pcall(getTitle, args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle()));
title, talk_title = getTitle(titleText);
if not good then
return htmlError(title);
end
 
if not title then
error('Invalid title ' .. titleText)
return htmlError('Page does not exist')
end
 
Line 98 ⟶ 84:
end
 
local ul = div:tag('ul');
:css('line-height', 'inherit'); -- otherwise, the default ul line height makes this take up 2 lines in navboxes, and makes the second line off-center
 
ul