Module:Navbar/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
sync changes from live, keeping mw.html support
Jackmcbarn (talk | contribs)
rm 2 unnecessary functions
Line 2:
 
local getArgs
 
local function trim(s)
return mw.ustring.match(s, "^%s*(.-)%s*$")
end
 
local function getTitle(pageName)
pageName = trim(pageName);
local page_title, talk_page_title;
 
if mw.ustring.sub(pageName, 1, 1) == ':' then
page_title = mw.title.new( mw.ustring.sub(pageName, 2));
else
page_title = mw.title.new(pageName, 'Template');
end
 
if page_title then
talk_page_title = page_title.talkPageTitle;
else
talk_page_title = nil;
end
 
return page_title, talk_page_title;
end
 
function p._navbar(args)
local title, talk_title;
local titleArg = 1
Line 42 ⟶ 18:
local titleText = args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local title, talk_title = getTitlemw.title.new(mw.text.trim(titleText), 'Template');
 
if not title then
Line 48 ⟶ 24:
end
 
local talk_title = title.talkPageTitle;
local mainpage = title.fullText;
local talkpage = talk_title and talk_title.fullText or ''