Difference between revisions of "Module:Biota infobox/test"
Jump to navigation
Jump to search
blackwiki>Jts1882 (create with skeleton convert taxobox function) |
blackwiki>Jts1882 (next step) |
||
| Line 6: | Line 6: | ||
function p.convert(frame) | function p.convert(frame) | ||
args = frame.args | args = frame.args | ||
| − | local template = {'{{speciesbox ' | + | local template = {} |
| + | local targs = {} | ||
| + | |||
| + | table.insert (template, '{{speciesbox ' ); | ||
for k,v in pairs(args) do | for k,v in pairs(args) do | ||
| + | |||
| + | if k == 'genus' then | ||
| + | local param = k:gsub("%'",""):gsub("%[",""):gsub("%]","") | ||
| + | k=param | ||
| + | v='Hypsiboas' | ||
| + | elseif k== 'species' then | ||
| + | v='albopunctatus' | ||
| + | end | ||
| + | |||
table.insert (template, table.concat ({' |'..k..'=', v})); | table.insert (template, table.concat ({' |'..k..'=', v})); | ||
| + | targs[k] = v | ||
end | end | ||
table.insert (template, '}}'); -- close the template | table.insert (template, '}}'); -- close the template | ||
| − | return table.concat (template, '\n'); | + | return frame:expandTemplate{ title = 'speciesbox', args = targs } |
| + | --return table.concat (template, '\n'); | ||
end | end | ||
return p | return p | ||
Revision as of 14:39, 28 January 2020
Documentation for this module may be created at Module:Biota infobox/test/doc
require('Module:No globals')
local p = {} -- exposed variables
local args = {}
function p.convert(frame)
args = frame.args
local template = {}
local targs = {}
table.insert (template, '{{speciesbox ' );
for k,v in pairs(args) do
if k == 'genus' then
local param = k:gsub("%'",""):gsub("%[",""):gsub("%]","")
k=param
v='Hypsiboas'
elseif k== 'species' then
v='albopunctatus'
end
table.insert (template, table.concat ({' |'..k..'=', v}));
targs[k] = v
end
table.insert (template, '}}'); -- close the template
return frame:expandTemplate{ title = 'speciesbox', args = targs }
--return table.concat (template, '\n');
end
return p