Module:descendants

Revision as of 22:23, 29 May 2024 by TheNightAvl (talk | contribs) (Created page with "--WORK IN PROGRESS -- local export = {} local getArgs = require("Module:Arguments").getArgs local m_links = require("Module:links") local m_languages = require("Module:languages") local m_inline = require("Module:inline") function export.descendant(frame) -- {{desc|rad|word1|word2...}} local args = getArgs(frame) local out = "" local lang = m_languages.get_by_code(args[1]) local borrowed = args["borrowed"] or args["bor"] or args["b"] local see_desc = args["s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Underlies {{descendant}} and {{descendant tree}}.


--[[
	WORK IN PROGRESS
]]--

local export = {}
local getArgs = require("Module:Arguments").getArgs
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local m_inline = require("Module:inline")

function export.descendant(frame) -- {{desc|rad|word1|word2...}}
	local args = getArgs(frame)
	local out = ""
	local lang = m_languages.get_by_code(args[1])
	local borrowed = args["borrowed"] or args["bor"] or args["b"]
	local see_desc = args["see"]
	local noname = args["noname"]
	local lostcap = args["lostcap"] or "lost"
	
	if borrowed then out = "<span class=\"desc-arrow\" title=\"borrowed\">→</span>" .. out end
	
	if not noname then out = out .. lang.name .. ":&nbsp;" end
	
	if args[2] then
		if see_desc then out = out .. frame:expandTemplate{ title = 'see descendants' } end
	else
		out = out .. "— (''" .. lostcap .. "'')"
	end
	
	return out
end

return export

--[[
Debug console test string:
=p.descendant(mw.getCurrentFrame():newChild{title="whatever",args={"rad"}})
]]--