Module:Sandbox/GKFX
Appearance
local p = {}
local uc = {births="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 args = frame.getParent().args
local decade = args[1] or '0'
local result = {}
local article_list = {}
local year_list = {}
if decade[1] == '-' then
for i = -9, (decade == '-0' and -1 or 0) do
article_list.insert(frame:expandTemplate {
name = "Year article",
args = { decade .. '0', tostring(i) }
})
year_list.insert(decade .. math.abs(i))
end
else
for i = (decade == '0' and 1 or 0), 9 do
article_list.insert(frame:expandTemplate {
name = "Year article",
args = { decade .. '0', tostring(i) }
})
year_list.insert(decade .. tostring(i))
end
end
for entry in ipairs({"births", "deaths"}) do
result.insert('== ' .. uc[entry] .. '==\n')
result.insert(frame:expandTemplate { name = "transcluding articles", args = article_list})
result.insert(transclude)
for i, article in ipairs(article_list) do
result.insert(transclude(frame, entry, year_list[i], article))
end
end
end
return p