Module:attention

From Linguifex
Revision as of 10:36, 29 April 2026 by Sware (talk | contribs) (Created page with "local export = {} local format_categories = require("Module:utilities").format_categories local html_create = mw.html.create local insert = table.insert local process_params = require("Module:parameters").process function export.show(frame) local args = process_params(frame:getParent().args, { [1] = {required = true, type = "language"}, [2] = true, ["id"] = true, ["sort"] = true, }) local lang = args[1] local lang_code = lang:getCode() local title = args[2...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:attention/doc

local export = {}

local format_categories = require("Module:utilities").format_categories
local html_create = mw.html.create
local insert = table.insert
local process_params = require("Module:parameters").process

function export.show(frame)
	local args = process_params(frame:getParent().args, {
		[1] = {required = true, type = "language"},
		[2] = true,
		["id"] = true,
		["sort"] = true,
	})
	local lang = args[1]
	local lang_code = lang:getCode()
	local title = args[2]
	local id = args["id"] or ""
	
	local categories = {"Requests for attention concerning " .. lang:getCanonicalName()}
	if not title then
		insert(categories, {cat = "attention lacking explanation", sort_key = "-"})
	end
	
	-- mw.html escapes special characters in the id and title attributes.
	local ret = html_create("span")
		:addClass("attentionseeking")
		:attr("data-lang", lang_code)
	
	if id ~= "" then
		ret = ret:attr("id", "attentionseeking" .. lang_code .. id)
	end
	
	if title then
		ret = ret:attr("title", title)
	end
	
	return tostring(ret) .. format_categories(categories, lang, args.sort)
end

return export