Module:Shortcut: Difference between revisions
use the number of shortcuts to generate the plural for the shortcut heading, rather than the number of list items; also, don't output the heading if we don't have any shortcuts to display
(add a nocat option to suppress category output) |
(use the number of shortcuts to generate the plural for the shortcut heading, rather than the number of list items; also, don't output the heading if we don't have any shortcuts to display) |
||
Line 34: | Line 34: | ||
end | end | ||
table.insert(listItems, options.msg) | table.insert(listItems, options.msg) | ||
-- Exit if we have nothing to display | -- Exit if we have nothing to display | ||
if | if #listItems < 1 then | ||
return nil | return nil | ||
end | end | ||
Line 56: | Line 55: | ||
-- Shortcut heading | -- Shortcut heading | ||
local shortcutHeading = mw.message.newRawMessage( | local shortcutHeading | ||
do | |||
local nShortcuts = #shortcuts | |||
if nShortcuts > 0 then | |||
shortcutHeading = mw.message.newRawMessage( | |||
cfg['shortcut-heading'], | |||
nShortcuts | |||
):plain() | |||
shortcutHeading = frame:preprocess(shortcutHeading) | |||
shortcutHeading = shortcutHeading .. '\n' | |||
end | |||
end | |||
-- Shortcut box | -- Shortcut box | ||
Line 79: | Line 85: | ||
:tag('small') | :tag('small') | ||
:wikitext(shortcutHeading) | :wikitext(shortcutHeading) | ||
:tag('ul') | :tag('ul') | ||
for i, item in ipairs(listItems) do | for i, item in ipairs(listItems) do |