Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  














Module:Births and deaths by year for decade







 

Edit links
 









Module
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Usage[edit]

{{#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="Births", deaths="Deaths"}

local page_content = {}
local function get_section(frame, page_name, section_name)
 if page_content[page_name] == nil then
  local title = mw.title.new(page_name)
  if title then
   if title.redirectTarget then title = title.redirectTarget end
   page_content[page_name] = title:getContent()
  end
 end
 if page_content[page_name] then
  if mw.ustring.find(page_content[page_name], "=%s*" .. section_name .. "%s*=", 1, false) then
   return frame:preprocess("{{#section-h::" .. page_name .. "|".. section_name .. "}}")
  end
 end
 return ""
end

local function transclude(frame, entry, year, article)
 local s = "'''{{dr|y|y|" .. year .. "|0|{{#ifexpr: " .. year ..
  " <= 100|na|n}}}}''' "
 s = frame:preprocess(s) .. get_section(frame, article, uc[entry])
 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] .. '==')
  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, "\n")
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Births_and_deaths_by_year_for_decade&oldid=1164670525"

Category: 
Modules in beta
 



This page was last edited on 10 July 2023, at 11:18 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki