Module:Shortcut: Difference between revisions

Jump to navigation Jump to search
95 bytes added ,  17 December 2014
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)
local nListItems = #listItems


-- Exit if we have nothing to display
-- Exit if we have nothing to display
if nListItems < 1 then
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
cfg['shortcut-heading'],
do
nListItems
local nShortcuts = #shortcuts
):plain()
if nShortcuts > 0 then
shortcutHeading = frame:preprocess(shortcutHeading)
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)
:newline()
:tag('ul')
:tag('ul')
for i, item in ipairs(listItems) do
for i, item in ipairs(listItems) do
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu