Модул:he-links

Документацију овог модула можете да направите на страници Модул:he-links/док

local m_links_templates = require("Module:links/templates")
local com = require("Module:he-common")

local export = {}

function export.term(frame)
	local args = {}

	for key, val in pairs(frame:getParent().args) do
		args[key] = val
	end

	if args["wv"] == "" then args["wv"] = nil end
	if args["dwv"] == "" then args["dwv"] = nil end

	if args[2] == nil or args[2] == "" then
		local form, formwv, formdwv = com.process_wv_triad(args[1] or "", args["wv"], args["dwv"])
		args[1] = form or ""
		if formdwv then
			args[2] = (formwv or form) .. " \\ " .. formdwv
		else
			args[2] = (formwv or form)
		end
	end

	args["wv"] = nil
	args["dwv"] = nil

	-- table.insert(args, 1, "he")
	-- shift manually to avoid strange bugs:
	args[4] = args[3]
	args[3] = args[2]
	args[2] = args[1]
	args[1] = "he"
	
	if args[3] and args[2]:find("[[", 1, true) then
		-- args[2] (term) contains wikilinks, so args[3] (alt) will be ignored
		-- by [[Module:links]] and will cause a tracking template to be
		-- transcluded.
		args[3] = nil
		-- [[Special:WhatLinksHere/Template:tracking/he-links/alt removed]]
		require("Module:debug").track("he-links/alt removed")
	end

	-- Passthrough arguments after modification
	local frame2 = frame:newChild{title = frame:getParent():getTitle(), args = args}:newChild{title = frame:getTitle(), args = frame.args}

	return m_links_templates.l_term_t(frame2)
end

return export