Module:Sandbox/RobLa/Foo
From Guild of Archivists
Testing my template: Lua error: bad argument #1 to 'gmatch' (string expected, got nil).
local str = require( 'Module:StringHelper' )
local p = {}
-- generate a bulleted list of section headings extracted from a page.
-- the page is passed as the first argument.
-- example: {{#invoke:Sandbox/RobLa/Foo|captions|Lua scripting/status}}
function p.captions( frame )
local title = frame.args[1]
local page = mw.title.new( title )
local content = page:getContent()
local captions = ''
for line in str.lines( content ) do
if str.startswith(line, '== ') and str.endswith(line, ' ==') then
item = '* ' .. str.strip( line, '= ') .. '\n'
captions = captions .. item
end
end
return captions
end
return p