Module:Create plant stub: Difference between revisions
Appearance
Content deleted Content added
add basic output |
adjust newline spacing |
||
Line 44: | Line 44: | ||
--speciesbox |
--speciesbox |
||
output = output .. " |
output = output .. "\n{{speciesbox" |
||
output = output .. " |
output = output .. "\n|image = " .. pargs['image'] or "" |
||
output = output .. " |
output = output .. "\n|genus = " .. genus .. "\n|species = " .. species |
||
output = output .. " |
output = output .. "\n}}" |
||
--lede |
--lede |
||
output = output .. " |
output = output .. "\n'''''" .. firstToUpper(genus) .. " " .. species .. "'''''" |
||
if common then |
if common then |
||
output = output .. ", also called the '''" .. common .. "'''," |
output = output .. ", also called the '''" .. common .. "'''," |
||
Line 62: | Line 62: | ||
-- end stuff |
-- end stuff |
||
output = output .. " |
output = output .. "\n==References==" |
||
output = output .. " |
output = output .. "\n{{reflist}}" |
||
output = output .. "\n\n{{taxonbar|from1=" .. (pargs['taxonbar'] or "") .. "}}" |
output = output .. "\n\n{{taxonbar|from1=" .. (pargs['taxonbar'] or "") .. "}}" |
||
output = output .. " |
output = output .. "\n" .. pargs['categories'] or "" |
||
return output |
return output |
Revision as of 15:13, 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{{speciesbox"
output = output .. "\n|image = " .. pargs['image'] or ""
output = output .. "\n|genus = " .. genus .. "\n|species = " .. species
output = output .. "\n}}"
--lede
output = output .. "\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==References=="
output = output .. "\n{{reflist}}"
output = output .. "\n\n{{taxonbar|from1=" .. (pargs['taxonbar'] or "") .. "}}"
output = output .. "\n" .. pargs['categories'] or ""
return output
end
return p