Module:links/templates: Difference between revisions

From Laenkea
Jump to navigation Jump to search
mNo edit summary
Tag: Reverted
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 10: Line 10:
[3] = {alias_of = "alt"},
[3] = {alias_of = "alt"},
["alt"] = {},
["alt"] = {},
["anchor"] = {},
[4] = {alias_of = "text"},
[4] = {alias_of = "text"},
["t"] = {alias_of = "text"},
["t"] = {alias_of = "text"},
["a"] = {alias_of = "anchor"},
["nolink"] = {type = "boolean"},
["hypo"] = {type = "boolean"},
["hypothetical"] = {alias_of = "hypo"},
["text"] = {},
["text"] = {},
["pos"] = {},
["pos"] = {},
["nobold"] = {type = "boolean"},
["nostar"] = {type = "boolean"},
}
}


Line 22: Line 29:
term = args[2],
term = args[2],
alt = args["alt"],
alt = args["alt"],
anchor = args["anchor"],
gloss = args["text"],
gloss = args["text"],
pos = args["pos"],
pos = args["pos"],
nobold = args["nobold"],
nostar = args["nostar"],
nolink = args["nolink"],
hypo = args["hypo"],
}
}
end
end
Line 38: Line 50:
local data = get_data(frame:getParent().args)
local data = get_data(frame:getParent().args)
data["showlanguage"] = true
data["showlanguage"] = true
data["nobold"] = true
return m_links.full_link(data, "term")
return m_links.full_link(data, "term")
end
end


return export
return export

Latest revision as of 15:59, 31 May 2024

Documentation for this module may be created at Module:links/templates/documentation

local export = {}

local m_links = require("Module:links")
local m_languages = require("Module:languages")
local m_parameters = require("Module:parameters")

local params = {
	[1] = {required = true},
	[2] = {required = true},
	[3] = {alias_of = "alt"},
	["alt"] = {},
	["anchor"] = {},
	[4] = {alias_of = "text"},
	["t"] = {alias_of = "text"},
	["a"] = {alias_of = "anchor"},
	["nolink"] = {type = "boolean"},
	["hypo"] = {type = "boolean"},
	["hypothetical"] = {alias_of = "hypo"},
	["text"] = {},
	["pos"] = {},
	["nobold"] = {type = "boolean"},
	["nostar"] = {type = "boolean"},
}

local function get_data(args)
	local args = m_parameters.process(args, params)
	return {
		language = m_languages.get_by_code(args[1]),
		term = args[2],
		alt = args["alt"],
		anchor = args["anchor"],
		gloss = args["text"],
		pos = args["pos"],
		nobold = args["nobold"],
		nostar = args["nostar"],
		nolink = args["nolink"],
		hypo = args["hypo"],
	}
end

function export.link(frame)
	return m_links.full_link(get_data(frame:getParent().args))
end

function export.mention(frame)
	return m_links.full_link(get_data(frame:getParent().args), "term")
end

function export.mention_with_language_name(frame)
	local data = get_data(frame:getParent().args)
	data["showlanguage"] = true
	return m_links.full_link(data, "term")
end

return export