Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Testing new idea for "custom" entry point
Undid revision 955466401 by Sophivorus (talk)
Line 816:
return table.concat(output)
end
 
local function transcludeCustom(frame)
local args = {}
for k, v in pairs(frame:getParent().args) do args[k] = v end
for k, v in pairs(frame.args) do args[k] = v end -- args from a Lua call have priority over parent args from template
 
local pageName = args[1]
options.paraflags = numberFlags(args["paragraphs"] or "") -- parse paragraphs: "1,3-5" to {"1","3-5"}
options.fileflags = numberFlags(args["files"] or "") -- parse file numbers
 
local text = main(pageNames, options)
return frame:preprocess(text)
end
 
-- Entry points for template callers using #invoke:
function p.custom(frame) return transcludeCustom(frame) end
function p.lead(frame) return invoke(frame, "lead") end -- {{Transclude lead excerpt}} reads the first and only article
function p.linked(frame) return invoke(frame, "linked") end -- {{Transclude linked excerpt}} reads a randomly selected article linked from the given page