אונטערשייד צווישן ווערסיעס פון "יחידה:Lexicon"

פון המכלול
קפיצה לניווט קפיצה לחיפוש
(צוריקדריי צו ווערסיע 197164 דורך צמא לדעת: נישט קיין return)
צייכן: צוריקגעשטעלט
אין תקציר עריכה
צייכן: מאנועל צוריקשטעל
 
(איין צווישנדיגע ווערסיע פונעם זעלבן באַניצער נישט געוויזן)
שורה 17: שורה 17:
local word = stripToNil(args[1])
local word = stripToNil(args[1])
local ret = data[word]
local ret = data[word]
mw.text.trim(ret)
if not ret then
if not ret then
if args[2] then
if args[2] then

יעצטיגע רעוויזיע זינט 10:57, 15 פעברואר 2023

מען קען שאפן דאקומענטאציע פאר דעם מאדול ביי יחידה:Lexicon/דאק

local p = {}

local function stripToNil(text)
	-- If text is a string, return its trimmed content, or nil if empty.
	-- Otherwise return text (which may, for example, be nil).
	if type(text) == 'string' then
		text = text:match('(%S.-)%s*$')
	end
	return text
end

function p.fetch(frame)
	-- Initialise and populate variables
	local getArgs = require("Module:Arguments").getArgs
	local args = getArgs(frame)
	local data = mw.loadData('יחידה:Lexicon/Data')
	local word = stripToNil(args[1])
	local ret = data[word]
	if not ret then
		if args[2] then
			ret = args[2]
		else
			ret = args[1]
	    end
	end
	return ret
end

return p