Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Documentation for this module may be created at Module:Lorem ipsum/doc

local yn = require("Module:Yesno")
local p = {}

function p._main(args)
	local paragraphs = {}
	local outTbl = setmetatable({}, {__call = function (t, v) t[#t+1] = v end})
	local link = yn(args["link"]) or yn(args[4]) or false
	local join = yn(args["join"]) or false
	local joinprefixsuffix = yn(args["joinprefixsuffix"]) or false
	local cat = yn(args["cat"]) or true
	local count = tonumber(args[1]) or 1
	local i = tonumber(args["start"]) or 1
	local data = mw.loadData(args["data"] or "Module:Lorem_ipsum/data")
	local maxLen = tonumber(args["max len"])
	for k,v in ipairs(data) do
		table.insert(paragraphs, v)
	end
	
	if join and (not joinprefixsuffix) then
		outTbl(args["prefix"] or args[2] or "")
	end

	while i > 0 and i <= count do
		if (not join) or joinprefixsuffix then
			outTbl(args["prefix"] or args[2] or "\n")
		end
		mw.log(count, i, data)
		outTbl(mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or "")))
		if not join then
			outTbl((args["suffix"] or args[3] or "") .. "\n")
		else
			if joinprefixsuffix then
				outTbl(args["suffix"] or args[3] or "")
			end
			outTbl(i == count and "" or " ")
		end
		link = false
		i = i + 1
	end
	if join and (not joinprefixsuffix) then
		outTbl(args["suffix"] or args[3] or "")
	end
	if cat and mw.title.getCurrentTitle().namespace == 0 and not mw.isSubsting() then
		outTbl("[[Category:Wikipedia articles containing placeholders]]")
	end
	local outStr = mw.getCurrentFrame():preprocess(table.concat(outTbl))
	return maxLen and mw.ustring.sub(outStr, 1, maxLen) or outStr
end

function p.main(frame)
	local args = require("Module:Arguments").getArgs(frame)
	return p._main(args, false)
end

function p.oneParagraph(frame)
	local args = require("Module:Arguments").getArgs(frame)
	args["join"] = true
	args["start"] = tonumber(args[1]) or 1
	return p._main(args)
end

return p