Module:WikiProject banner/sandbox: Difference between revisions

Content deleted Content added
frameOnly
move parameter check to function
Line 134:
table.sort(notes, function (x, y) return tonumber(x) < tonumber(y) end)
local warning = ''
---------------------------
-- Unknown parameters -----
---------------------------
local parameter_check = ''
if invoke and banner_name.exists then
local parent_args = args_module.getArgs(frame, {parentOnly = true})
local template_code = banner_name:getContent()
local parameters = {}
for parameter in template_code:gmatch('{{{([^|]+)') do
table.insert(parameters, parameter)
end
parameters.preview = cfg.unknown_parameters.preview:format(wikilink(banner_name.fullText))
local unknown_category = cfg.unknown_parameters.tracking:format(project_name)
parameters.unknown = mw.title.new(unknown_category).exists and '[[' .. unknown_category .. '|_VALUE_]]' or ''
if demo then parameters.unknown = '' end
parameter_check = require('Module:Check for unknown parameters')._check(parameters, parent_args)
end
---------------------------
-- Location warning -------
Line 678 ⟶ 661:
local tstyle = frame:extensionTag ('templatestyles', '', {src='Module:Message box/tmbox.css'}) ..
frame:extensionTag ('templatestyles', '', {src = 'Module:WikiProject banner' .. (sandbox or '') .. '/styles.css'})
return parameter_check .. warning .. tstyle .. tostring(banner) .. table.concat(categories), note_count, #taskforce_output, assessment_link
end
 
local parameter_check = ''function(frame, banner_name)
---------------------------
-- Unknown parameters -----
---------------------------
if invoke andnot banner_name.exists then
return nil
end
local parent_args = args_module.getArgs(frame, {parentOnly = true})
local template_code = banner_name:getContent()
local parameters = {}
for parameter in template_code:gmatch('{{{([^|]+)') do
table.insert(parameters, parameter)
end
parameters.preview = cfg.unknown_parameters.preview:format(wikilink(banner_name.fullText))
local unknown_category = cfg.unknown_parameters.tracking:format(project_name)
parameters.unknown = mw.title.new(unknown_category).exists and '[[' .. unknown_category .. '|_VALUE_]]' or ''
parameter_check =return require('Module:Check for unknown parameters')._check(parameters, parent_args)
end
 
Line 689 ⟶ 691:
)
local invoke = frame.args.PROJECT and frame.args.PROJECT~='' -- checks whether banner template is using {{#invoke:WikiProject banner}}
local unknown_parameters = banner_name.exists and not demo and parameter_check(frame, banner_name) or ''
if on_template_page then
local templatepage = require('Module:WikiProject banner/templatepage' .. (sandbox or '')).templatepage
return templatepage(args, raw_args, invoke, inactive)
else
return unknown_parameters .. p._main(args, raw_args, demo or inactive, banner_name, invoke), nil -- nil to disregard subsequent returned values
end
end