Module:Numbered subpages/sandbox: Difference between revisions
Appearance
Content deleted Content added
Dreamy Jazz (talk | contribs) testing |
Dreamy Jazz (talk | contribs) some more testing |
||
Line 25: | Line 25: | ||
maxk = (maxk > (mink + 250)) and (mink + 250) or maxk |
maxk = (maxk > (mink + 250)) and (mink + 250) or maxk |
||
for i=mink,maxk do |
for i=mink,maxk do |
||
if headertemplateno ~= '' then |
|||
i.headertemplateno = headertemplateno |
|||
⚫ | |||
if missing == 'transclude' then |
if missing == 'transclude' then |
||
res = res .. frame:expandTemplate{title = 'subpage', args = { i } } |
if headertemplateno == '' then |
||
res = res .. frame:expandTemplate{title = 'subpage', args = { i } } |
|||
else |
|||
res = res .. frame:expandTemplate{title = 'subpage', args = { i, headertemplateno=headertemplateno } } |
|||
⚫ | |||
else |
else |
||
if ifexist(root .. '/' .. i) then |
if ifexist(root .. '/' .. i) then |
||
res = res .. frame:expandTemplate{title = 'subpage', args = { i } } |
if headertemplateno == '' then |
||
res = res .. frame:expandTemplate{title = 'subpage', args = { i } } |
|||
else |
|||
res = res .. frame:expandTemplate{title = 'subpage', args = { i, headertemplateno=headertemplateno } } |
|||
end |
|||
else |
else |
||
if missing == 'link' then |
if missing == 'link' then |
Revision as of 21:11, 18 July 2018
![]() | This is the module sandbox page for Module:Numbered subpages (diff). |
Implements {{Numbered subpages}}
-- This module implements {{numbered subpages}}.
local getArgs = require('Module:Arguments').getArgs
p = {}
local function ifexist(page)
if not page then return false end
if mw.title.new(page).exists then return true end
return false
end
function p.main(frame)
local args = getArgs(frame)
local maxk = tonumber(args.max or '50') or 50
local mink = tonumber(args.min or '1') or 1
local root = ''
local missing = args.missing or (args.max and 'transclude' or 'skip')
local res = ''
local headertemplateno = args.headertemplateno or ''
if missing ~= 'transclude' then
root = frame:preprocess('{{FULLPAGENAME}}')
end
maxk = (maxk > (mink + 250)) and (mink + 250) or maxk
for i=mink,maxk do
if missing == 'transclude' then
if headertemplateno == '' then
res = res .. frame:expandTemplate{title = 'subpage', args = { i } }
else
res = res .. frame:expandTemplate{title = 'subpage', args = { i, headertemplateno=headertemplateno } }
end
else
if ifexist(root .. '/' .. i) then
if headertemplateno == '' then
res = res .. frame:expandTemplate{title = 'subpage', args = { i } }
else
res = res .. frame:expandTemplate{title = 'subpage', args = { i, headertemplateno=headertemplateno } }
end
else
if missing == 'link' then
res = res .. '[[' .. root .. '/' .. i .. ']] '
elseif missing == 'stop' then
i = maxk + 1
end
end
end
end
return res
end
return p