Module:Events by year for decade
Implements {{Events by year for decade}}
local p = {}
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("\n{{#section-h::" .. page_name .. "|".. section_name .. "}}")
end
end
return ""
end
p.main = function(frame)
frame.args = frame:getParent().args
return p[''](frame)
end
p[''] = function(frame)
local output = {
frame:expandTemplate{ title = 'TOC limit', args = {3} },
'\n==Events==\n'
}
local n = tonumber((frame.args[1] or '0') .. '0') or 0
for i = n, n + 9 do
if i == 0 then output[3] = '' else
local year = frame:expandTemplate{ title='dr', args={'y', 'y', i, 0, n < 100 and 'na' or 'n'}}
local year2 = frame:expandTemplate{ title='dr', args={'y', 'y', i, 0, n <= 1000 and 'na' or 'n'}}
local section = '== ' .. year .. '==\n' .. mw.text.trim(
frame:expandTemplate{ title ='transcluded section', args = { year2 }} .. ' ' ..
get_section(frame,year2, 'Events')) .. '\n'
output[1 + #output] = section:gsub('==', '===')
end
end
if 'Template:Events by year for decade' ~= mw.title.getCurrentTitle().fullText then
output[13] = '[[Category:' .. n ..'s]]'
end
return table.concat(output)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.