Module:Shortcut: Difference between revisions

from sandbox
(Implement merger code by Pppery)
(from sandbox)
Line 24:
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = yesno(options.template)
local floatLeft = options.float and options.float:lower() == 'left'
local isCategorized = yesno(options.category) ~= false
 
Line 37 ⟶ 39:
local listItems = {}
for i, shortcut in ipairs(shortcuts) do
local templatePath
if yesno(options['target']) then
if templateMode then
listItems[i] = string.format("[[%s]]",shortcut)
-- Namespace detection
local titleObj = mw.title.new(shortcut, 10)
if titleObj.namespace == 10 then
templatePath = titleObj.fullText
else
templatePath = shortcut
end
end
if yesno(options['.target']) then
listItems[i] = templateMode
and string.format("{{[[%s|%s]]}}", templatePath, shortcut)
listItems[i] = or string.format("[[%s]]", shortcut)
else
listItems[i] = frame:expandTemplate{
title = 'No redirect',
args = templateMode and {templatePath, shortcut} or {shortcut}
}
if templateMode then
listItems[i] = string.format("{{%s}}", listItems[i])
end
end
end
Line 85 ⟶ 102:
:addClass('module-shortcutboxplain plainlist noprint')
:attr('role', 'note')
if floatLeft then
shortcutList:addClass('module-shortcutboxleft')
end
if shortcutHeading then
shortcutList
Anonymous user