Module:anchor

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module implements the template {{anchor}}.


local html_create = mw.html.create
local process_params = require("Module:parameters").process
local tostring = tostring

local export = {}

function export.main(frame)
	local args = process_params(frame:getParent().args, {
		{required = true, list = true},
	})[1]
	
	local anchors = html_create()
	for i = 1, #args do
		anchors = anchors:tag("span")
			:addClass("template-anchor")
			:attr("id", args[i])
			:done()
	end
	
	return tostring(anchors)
end

return export