Module:Shortcut/sandbox: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
m sync with main
Line 24:
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = yesno(options.template)
local isCategorized = yesno(options.category) ~= false
 
Line 33 ⟶ 32:
end
end
 
 
-- Make the list items. These are the shortcuts plus any extra lines such
Line 39 ⟶ 37:
local listItems = {}
for i, shortcut in ipairs(shortcuts) do
if yesno(options.['target']) then
local templatePath
orlistItems[i] = string.format("[[%s]]", shortcut)
if templateMode then
-- 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)
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