Module:Excerpt: Difference between revisions

Content deleted Content added
Removing {{#tag:ref ... }}
For lead, ignore all but the first unnamed argument
Line 95:
end
 
-- Shared template invocation code for lead and random functions
-- Entry point for template callers using #invoke:
function p.leadleadrandom(frame, israndom)
-- args = { 1,2,... = page namenames, paragraphs = list e.g. "1,3-5", files = list, more = text}
local args = frame.args -- from calling module
local pargs = frame:getParent().args -- from template
 
local pagenames = { args[1] or pargs[1] } -- For lead, ignore all but the first unnamed argument
-- Accept any number of page names. If more than one, we'll pick one randomly
if israndom then
local pagenames = {}
-- AcceptFor random, accept any number of page names. If more than one, we'll pick one randomly
for i, p in pairs(args) do
for i, p in pairs(args) do
if p and type(i) == 'number' and i > 1 then table.insert(pagenames, p) end
end
for i, p in pairs(pargs) do
if p and type(i) == 'number' and i > 1 and not args[i] then table.insert(pagenames, p) end
end
end
 
Line 120 ⟶ 122:
end
 
-- Entry pointpoints for template callers using #invoke:
-- Function lead is just function random picking from a list of one article,
function p.lead(frame) return p.leadrandom(frame, false) end
-- but we advertise different entry points in case they should differ in future
function p.random(frame) return p.leadrandom(frame, true) end
return p.lead(frame)
end
 
return p