420
edits
HyperNervie (talk | contribs) (More flags) |
HyperNervie (talk | contribs) m (Replace " " with "\t") |
||
| Line 2: | Line 2: | ||
local function trim(str) | local function trim(str) | ||
if str == nil then return nil end | |||
return mw.text.trim(tostring(str)) | |||
end | end | ||
| Line 13: | Line 13: | ||
function p.main(frame) | function p.main(frame) | ||
local args = {} | |||
for k, v in pairs(frame.args) do | |||
args[k] = v | |||
end | |||
for k, v in pairs(frame:getParent().args) do | |||
args[k] = v | |||
end | |||
return p.makeLink(args) | |||
end | end | ||
| Line 38: | Line 38: | ||
end | end | ||
local linkedTitle = mw.title.new(templateName, "Template") | |||
if linkedTitle == nil then | |||
error(mw.ustring.format([["%s" isn't a valid title]], templateName)) | |||
end | |||
local slash = mw.ustring.sub(templateName, 1, 1) == "/" | |||
if slash then | |||
linkedTitle = mw.title.new(templateName) | |||
end | |||
local titleText = linkedTitle.fullText | |||
local linkText = linkedTitle.text | |||
if slash then | |||
-- Do nothing | |||
elseif linkedTitle.nsText == "" then | |||
titleText = ":" .. titleText | |||
linkText = ":" .. linkText | |||
elseif linkedTitle.nsText ~= "Template" then | |||
linkText = linkedTitle.prefixedText | |||
end | |||
local output | local output | ||
| Line 76: | Line 76: | ||
local html | local html | ||
if yes(args.code) then | |||
html = mw.html.create("code") | html = mw.html.create("code") | ||
elseif yes(args.mono) then | elseif yes(args.mono) then | ||
html = mw.html.create("span"):css("font-family", "monospace") | html = mw.html.create("span"):css("font-family", "monospace") | ||
end | |||
if yes(args.nowrap) then | if yes(args.nowrap) then | ||
if html == nil then html = mw.html.create("span") end | if html == nil then html = mw.html.create("span") end | ||
| Line 89: | Line 89: | ||
end | end | ||
return output | |||
end | end | ||
return p | return p | ||
edits