Module:Births and deaths by year for decade
Appearance
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
Related pages |
---|
Usage
[සංස්කරණය]{{#invoke:Births and deaths by year for decade|main|169}}
displays births and deaths of the 1690s. For further details see {{Births and deaths by year for decade}}.
local p = {}
local uc = {births="උපත්", deaths="Deaths"}
local function transclude(frame, entry, year, article)
local s = "'''{{dr|y|y|" .. year .. "|0|{{#ifexpr: " .. year ..
" <= 100|na|n}}}}''' {{#section-h::" .. article .. "|".. uc[entry] .."}}"
s = frame:preprocess(s)
s = mw.ustring.gsub(s, '==+[^=]-==+%s*%c*', '')
return mw.ustring.match(s, '.*%*.*%a.+')
end
function p.main(frame)
local decade = mw.text.trim(frame.args[1] or frame:getParent().args[1] or '0')
local result = {}
local article_list = {}
local year_list = {}
if decade:sub(1, 1) == '-' then
for i = -9, (decade == '-0' and -1 or 0) do
table.insert(article_list, frame:expandTemplate {
title = "Year article",
args = { decade .. '0', tostring(i) }
})
table.insert(year_list, decade .. math.abs(i))
end
else
for i = (decade == '0' and 1 or 0), 9 do
table.insert(article_list, frame:expandTemplate {
title = "Year article",
args = { decade .. '0', tostring(i) }
})
table.insert(year_list, decade .. tostring(i))
end
end
for i, entry in ipairs({"births", "deaths"}) do
table.insert(result, '== ' .. uc[entry] .. '==\n')
table.insert(result, frame:expandTemplate { title = "transcluding article", args = article_list})
for i, article in ipairs(article_list) do
table.insert(result, transclude(frame, entry, year_list[i], article))
end
end
return table.concat(result)
end
return p