Jump to content

Modulus:Svg

E Vicipaedia
Redactio 07:27, 19 Octobris 2025 a conlatore Grufo (disputatio | conlationes) facta (Modulum e Vicipaedia Anglica intuli)
(diff) ← Redactio superior | Redactio novissima (diff) | Redactio recentior → (diff)
Icon documentationis Documentatio moduli[crea]
require[[strict]]


local iface = {}


iface.create = function (frame)
	local opts = frame.args
	local src
	local target
	if opts.content ~= nil then src = opts.content:match'^%s*(.*%S)' end
	if opts.link ~= nil then target = opts.link:match'^%s*(.*%S)' end
	if src == nil then return '' end
	local img = mw.svg.new()
	for key, val in pairs(opts) do
		if key ~= 'content' and key ~= 'link' and type(key) == 'string' then
			if key:sub(1, 1) == '#' then
				img:setAttribute(key:sub(2), val)
			else img:setImgAttribute(key, val) end
		end
	end
	if target == nil then return img:setContent(src):toImage() end
	return '[[:' .. target .. '|' .. img:setContent(src):toImage() .. ']]'
end


iface.create_from_caller = function (frame)
	return iface.create(frame:getParent())
end


return iface