Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
handle nils
Jackmcbarn (talk | contribs)
get ready for use
Line 1:
local p = {}
 
function p.mainmark(frame)
local argsToReturn = {}
local extra = {}
local args = {}
for k,v in pairs({'lat', 'long', 'mark', 'marksize', 'label', 'link', 'label_size', 'position'}) do
if for k,v in pairs(frame.args[v]) thendo
frame.args[vk] = nilv
argsToReturn[k] = string.format("%s = %q", v, mw.text.trim(frame.args[v]))
end
frame.args[v] = nil
for k,v in pairsipairs({'lat', 'long', 'mark', 'marksize', 'label', 'link', 'label_size', 'position'}) do
if args[v] then
argsToReturn[k] = string.format("%s = %q", v, mw.text.trim(frame.args[v]))
args[v] = nil
end
end
if frame.args[1] and mw.text.trim(frame.args[1]) == 'Syria' then frame.args[1] = nil end
for k,v in pairs(frame.args) do
table.insert(extra, 'EXTRA ' .. k .. ' = ' .. v)
end
if #extra > 0 then
return '{ ' .. table.concat(argsToReturn, ', ') .. ' }' .. table.concat(extra, ', ')
error(table.concat(extra, ', '))
end
return '{ ' .. table.concat(argsToReturn, ', ') .. ' }' .. table.concat(extra, ', ')
end