Module:Section link: Difference between revisions

actually, just make the sections optional
(fix error placement and tweak default conjunction)
(actually, just make the sections optional)
Line 15:
checkType('_main', 1, page, 'string', true)
checkType('_main', 3, options, 'table', true)
if type(sections) == 'string'nil then
if #sections < 1= then{}
elseif type(sections) == 'string' then
sections = {sections}
elseif type(sections) ~= 'table' then
error(string.format(
"type error in argument #2 to '_main' (string" or table expected, got %s)",..
"(string, table or nil expected, got %s)",
type(sections)
), 2)
Line 28 ⟶ 31:
-- Make the link(s).
local isShowingPage = not options.nopage
if #sections =<= 1 then
local linkPage = page or ''
local section = sections[1] or 'Notes'
Line 38 ⟶ 41:
return makeSectionLink(linkPage, section, display)
else
-- Multiple sections. First, validatemake a list of the sectionslinks to tabledisplay.
if #sections < 1 then
error('at least one section must be specified', 2)
end
 
-- Make the list of links.
local ret = {}
for i, section in ipairs(sections) do