Module:Sandbox/Gonnym/TQ

Revision as of 20:32, 17 February 2022 by imported>Gonnym
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/Gonnym/TQ/doc

local p = {}

local function _main(args)
	if mw.title.getCurrentTitle().namespace == 0 then
		return error("Talk quote inline is only for quoting in talk and project pages. Do not use it in actual articles")
	end

	local title = ""
	if args.title then
		title = 'title=' .. args.title
	end

	local italic = ""
	if args.i or args.italic then
		italic = "inline-quote-talk-italic"
	end

	local quotes = ""
	if args.q or args.quotes then
		quotes = "inline-quote-talk-marks"
	end
	
	local text = args[1] or "Example text"
	local formatted_text = '<q %s class="inline-quote-talk" %s %s"> %s</q>'
	
	local templatestyles = mw.getCurrentFrame():extensionTag{name = "templatestyles", args = {src = "Template:Talk quote inline/styles.css"}}
	return templatestyles .. string.format(formatted_text, title, italic, quotes, text)
end

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

return p