Module:links/templates: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:
}
}


local function get_data(frame)
local function get_data(args)
local args = m_parameters.process(frame:getParent(), params)
local args = m_parameters.process(args, params)
return {
return {
term = args[1],
term = args[1],
Line 26: Line 26:


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


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


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

Revision as of 14:18, 6 August 2023

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"] = {},
	[4] = {alias_of = "text"},
	["t"] = {alias_of = "text"},
	["text"] = {},
}

local function get_data(args)
	local args = m_parameters.process(args, params)
	return {
		term = args[1],
		language = m_languages.get_by_code(args[2]),
		alt = args["alt"],
		gloss = args["text"],
	}
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