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 = | 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: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 | if isnotempty(frame.args['preview']) then | ||
if ispreview == 1 | 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 |