Anonymous user
Module:Template test case: Difference between revisions
add the option defaults before we compress the table to fix the case where the first numbered argument is higher than 2
(fix error message for missing template parameters and remove dependency on Module:TableTools) |
(add the option defaults before we compress the table to fix the case where the first numbered argument is higher than 2) |
||
Line 155:
obj.cfg = cfg
-- Separate
-- numbered, whereas general options are not.
local generalOptions, templateOptions = {}, {}
do
local optionNum = {} -- a unique key for option numbers inside templateOptions
local rawTemplateOptions = {}
Line 175:
end
end
rawTemplateOptions[1] = rawTemplateOptions[1] or {}
rawTemplateOptions[2] = rawTemplateOptions[2] or {}
'/' .. obj.cfg.sandboxSubpage▼
obj.cfg.sandboxSubpage▼
)▼
-- Remove gaps in the numbered options
local nums = {}
Line 184 ⟶ 201:
templateOptions[i] = rawTemplateOptions[num]
end
-- Check that there are no missing template options.
for i = 3, #templateOptions do -- Defaults
local t = templateOptions[i]
if not t.template then
Line 201 ⟶ 219:
generalOptions.collapsible = yesno(generalOptions.collapsible)
obj.options = generalOptions
▲ -- Add default template options
▲ if templateOptions[1].template and not templateOptions[2].template then
▲ templateOptions[2].template = templateOptions[1].template ..
▲ '/' .. obj.cfg.sandboxSubpage
▲ end
▲ if not templateOptions[1].template then
▲ templateOptions[1].title = mw.title.getCurrentTitle().basePageTitle
▲ end
▲ if not templateOptions[2].template then
▲ templateOptions[2].title = templateOptions[1].title:subPageTitle(
▲ obj.cfg.sandboxSubpage
▲ )
▲ end
-- Make the template objects
|