Module:Create plant stub: Difference between revisions
Appearance
Content deleted Content added
create with basic outline |
add basic output |
||
Line 3: | Line 3: | ||
local pargs = {} |
local pargs = {} |
||
local function firstToUpper(str) |
|||
return (str:gsub("^%l", string.upper)) |
|||
end |
|||
local function getArgs (frame, args) |
local function getArgs (frame, args) |
||
Line 26: | Line 29: | ||
getArgs(frame,pargs) |
getArgs(frame,pargs) |
||
local genus = pargs['genus'] |
|||
local species = pargs['species'] |
|||
local common = pargs['common_name'] |
|||
if not (genus and species) then |
|||
return "ERROR: require genus and species parameter" |
|||
end |
|||
local output = "" |
|||
local short = pargs['short'] or "Species of plant in the genus " ..pargs['genus'] |
|||
output = output .. "{{short description|" .. short .. "}}" |
|||
--speciesbox |
|||
output = output .. "\n\n{{speciesbox" |
|||
output = output .. "\n\n|image = " .. pargs['image'] or "" |
|||
output = output .. "\n\n|genus = " .. genus .. "\n\n|species = " .. species |
|||
output = output .. "\n\n}}" |
|||
--lede |
|||
output = output .. "\n\n'''''" .. firstToUpper(genus) .. " " .. species .. "'''''" |
|||
if common then |
|||
output = output .. ", also called the '''" .. common .. "'''," |
|||
end |
|||
output = output .. " is a species of " .. pargs['type'] or "flowering plant" .. "in the genus ''[[" ..genus "]]''" |
|||
if pargs['distribution'] then |
|||
output = output .. ", native to " .. pargs['distribution'] |
|||
end |
|||
output = output .. ". " .. (pargs['comment'] or "") |
|||
-- end stuff |
|||
output = output .. "\n\n==References==" |
|||
output = output .. "\n\n{{reflist}}" |
|||
output = output .. "\n\n{{taxonbar|from1=" .. (pargs['taxonbar'] or "") .. "}}" |
|||
output = output .. "\n\n" .. pargs['categories'] or "" |
|||
return output |
|||
return "Species called ''" .. pargs['genus'] .. " " .. pargs['species'] .. " (" .. pargs['common_name'] .. ")" |
|||
end |
end |
Revision as of 14:58, 31 January 2021
require('Module:No globals')
local p = {}
local pargs = {}
local function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
local function getArgs (frame, args)
local parents = mw.getCurrentFrame():getParent()
for k,v in pairs(parents.args) do
--check content
if v and v ~= "" then
args[k]=v --parents.args[k]
end
end
for k,v in pairs(frame.args) do
--check content
if v and v ~= "" then
args[k]=v
end
end
end
p.main = function (frame)
getArgs(frame,pargs)
local genus = pargs['genus']
local species = pargs['species']
local common = pargs['common_name']
if not (genus and species) then
return "ERROR: require genus and species parameter"
end
local output = ""
local short = pargs['short'] or "Species of plant in the genus " ..pargs['genus']
output = output .. "{{short description|" .. short .. "}}"
--speciesbox
output = output .. "\n\n{{speciesbox"
output = output .. "\n\n|image = " .. pargs['image'] or ""
output = output .. "\n\n|genus = " .. genus .. "\n\n|species = " .. species
output = output .. "\n\n}}"
--lede
output = output .. "\n\n'''''" .. firstToUpper(genus) .. " " .. species .. "'''''"
if common then
output = output .. ", also called the '''" .. common .. "''',"
end
output = output .. " is a species of " .. pargs['type'] or "flowering plant" .. "in the genus ''[[" ..genus "]]''"
if pargs['distribution'] then
output = output .. ", native to " .. pargs['distribution']
end
output = output .. ". " .. (pargs['comment'] or "")
-- end stuff
output = output .. "\n\n==References=="
output = output .. "\n\n{{reflist}}"
output = output .. "\n\n{{taxonbar|from1=" .. (pargs['taxonbar'] or "") .. "}}"
output = output .. "\n\n" .. pargs['categories'] or ""
return output
end
return p