Jump to content

Module:Lorem ipsum

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Awesome Aasim (talk | contribs) at 23:48, 23 April 2024 (Restored revision 1220424025 by Awesome Aasim (talk)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

return {
	main = function(frame)
		local args = require("Module:Arguments").getArgs(frame)
		local data = args["data"] and mw.loadData(args["data"]) or mw.loadData("Module:Lorem_ipsum/data")
		local paragraphs = {}
		for k,v in ipairs(data) do
			table.insert(paragraphs, v)
		end
		local out = ''
		local link = require("Module:Yesno")(args["link"]) or require("Module:Yesno")(args[4]) or false
		local join = require("Module:Yesno")(args["join"]) or false
		local count = tonumber(args[1] or 1)
		local i = 1
		if join then
			out = out .. (args["prefix"] .. " " or args[2] .. " " or "")
		end
		while i <= count do
			if not join then
				out = out .. (args["prefix"] .. " " or args[2] .. " " or "\n")
			end
			out = out .. mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or ""))
			if not join then
				out = out .. (" " .. args["suffix"] or " " ..args[3] or "") .. "\n"
			else
				out = out .. " "
			end
			link = false
			i = i + 1
		end
		if join then
			out = out .. (" " .. args["suffix"] or " " .. args[3] or " ")
		end
		return frame:preprocess(out)
	end,
	oneParagraph = function(frame)
		local args = require("Module:Arguments").getArgs(frame)
		local data = args["paragraphs"] and mw.loadData(args["paragraphs"]) or mw.loadData("Module:Lorem_ipsum/data")
		local paragraphs = {}
		for k,v in ipairs(data) do
			table.insert(paragraphs, v)
		end
		local i = tonumber(args[1] or 1)
		local link = require("Module:Yesno")(args["link"])
		return frame:preprocess(mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or "")))
	end
}