Module:User:DTLHS/subpages

export = {}

function namespace(title) for i in mw.ustring.gmatch(title, '[^:]+:') do		return i	end return '' end

function load_page(frame, pagename) return frame:expandTemplate{ title = ':' .. pagename } end

function all_subpages(frame, pagename) local result = {} local index = mw.text.unstrip(frame:preprocess('')) local ns = namespace(pagename) for link in mw.ustring.gmatch(index, "(.-)") do   	table.insert(result, ns..link) end return result end

function export.display(frame) local args = frame:getParent.args local pagename = args[1] local pages = all_subpages(frame, pagename) local result = {} for i, v in ipairs(pages) do		table.insert(result, load_page(frame, v)) end return table.concat(result, '\n\n') end

return export