Module:shortcut box: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
for _, shortcut in ipairs(shortcuts) do | for _, shortcut in ipairs(shortcuts) do | ||
if string.sub(shortcut, 1, 9) == "Template:" then | if string.sub(shortcut, 1, 9) == "Template:" then | ||
table.insert(text, m_template.make_template({[1] = string.sub(shortcut, 10)}, false)) | table.insert(text, '<span style="font-size:110%">' .. m_template.make_template({[1] = string.sub(shortcut, 10)}, false) .. '</span>') | ||
else | else | ||
table.insert(text, shortcut) | table.insert(text, '<span style="font-size:110%">[[' .. shortcut .. ']]</span>') | ||
end | end | ||
end | end |
Revision as of 14:45, 7 August 2023
Documentation for this module may be created at Module:shortcut box/documentation
local export = {}
local m_message_box = require("Module:Message box")
local m_template = require("Module:template")
function export.format_shortcuts(shortcuts)
local text = {}
for _, shortcut in ipairs(shortcuts) do
if string.sub(shortcut, 1, 9) == "Template:" then
table.insert(text, '<span style="font-size:110%">' .. m_template.make_template({[1] = string.sub(shortcut, 10)}, false) .. '</span>')
else
table.insert(text, '<span style="font-size:110%">[[' .. shortcut .. ']]</span>')
end
end
return table.concat(text, "\n")
end
function export.render_box(shortcuts)
local formatted_shortcuts = export.format_shortcuts(shortcuts)
return m_message_box.main("mbox", {
text = "'''Shortcut'''\n<hr style=\"margin-bottom:6px;\"/>\n" .. formatted_shortcuts,
type = "notice",
small = true,
image = "none",
style = "text-align:center; width: auto;",
})
end
function export.show(frame)
return export.render_box(frame:getParent().args)
end
return export