توضیحات پودمان[ایجاد] [پاکسازی]
-- This is a meta-module for producing block quotations
local getArgs = require('Module:Arguments').getArgs

local blockquote = {}
blockquote.__index = blockquote

function blockquote.new()
	local obj = {}
	obj.classes = { 'templatequote' }
	setmetatable(obj, blockquote)
	return obj
end

function blockquote:setBlockquoteParameters(args)
	self.quote = args.quote
	self.author = args.author
	if args.bordered then
		self:addClass('toccolours')
	end
	if args.fit then
		self:addStyle('display:table;')
	end
	self:addStyle(args.style);
end

function blockquote:addClass(class)
	if type(class) ~= 'string' then return end
	self.classes = self.classes or {}
	table.insert(self.classes, class)
end

function blockquote:addStyle(style)
	if type(style) ~= 'string' then return end
	self.style = self.style or ''
	self.style = self.style .. style
end

function blockquote:export()
	local aquote = mw.html.create( 'blockquote' )

	if self.id then
		aquote:attr('id', self.id)
	end
	
	for i, class in ipairs(self.classes or {}) do
		aquote
			:addClass(class)
	end
	aquote:cssText(self.style)

	aquote:wikitext(self.quote)
	
	-- Add a <footer> (or <div> for now) with the citation
	if self.author or self.source then
		aquote:tag('div')
			:addClass('templatequotecite')
			:wikitext(self.author);
	end

	return tostring(aquote)
end

local function main(args)
	local bq = blockquote.new()
	bq:setBlockquoteParameters(args)
	return bq:export()
end

local function mainFrame(frame)
	local args = getArgs(frame, {trim = false, removeBlanks = false})
	main(args)
end

local p = {
	main = mainFrame,
	test = main
}

return p