Module:Check for unknown parameters: Difference between revisions

improve logic
m>Frietjes
(blank check)
m>Frietjes
(improve logic)
Line 18: Line 18:
local checkpos = isnotempty(frame.args['checkpositional'])
local checkpos = isnotempty(frame.args['checkpositional'])
local knownargs = {}
local knownargs = {}
local unknown = 'Found _VALUE_, '
local unknown = frame.args['unknown'] or 'Found _VALUE_, '
local preview = nil
local preview = frame.args['preview'] or unknown


local res = {}
local res = {}
Line 33: Line 33:
v = trim(v)
v = trim(v)
knownargs[v] = 1
knownargs[v] = 1
elseif k == 'unknown' and ispreview == 0 then
unknown = v
elseif k == 'preview' and ispreview == 1 then
preview = v
elseif k:find('^regexp[1-9][0-9]*$') then
elseif k:find('^regexp[1-9][0-9]*$') then
table.insert(regexps, '^' .. v .. '$')
table.insert(regexps, '^' .. v .. '$')
end
end
end
end
if preview and preview ~= '' then preview = '<div class="hatnote" style="color:red"><strong>Warning:</strong> ' .. preview .. ' (this message is shown only in preview).</div>' end
if isnotempty(frame.args['preview']) then  
if ispreview == 1 and preview then unknown = preview end
preview = '<div class="hatnote" style="color:red"><strong>Warning:</strong> ' .. frame.args['preview'] .. ' (this message is shown only in preview).</div>'
elseif frame.args['preview'] then
preview = frame.args['preview']
else
preview = unknown
end
if ispreview == 1 then unknown = preview end
-- adds one result to the output tables
-- adds one result to the output tables
Anonymous user