Modul:Yesno: Unterschied zwischen den Versionen

Aus Kryptowiki - Die freie Enzyklopädie der Kryptowährungen
Wechseln zu: Navigation, Suche
(recognise "t" for true and "f" for false, per request)
 
K (1 Version importiert)
 
(2 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 14: Zeile 14:
 
or val == 'true'
 
or val == 'true'
 
or val == 't'
 
or val == 't'
 +
or val == 'on'
 
or tonumber(val) == 1
 
or tonumber(val) == 1
 
then
 
then
Zeile 22: Zeile 23:
 
or val == 'false'
 
or val == 'false'
 
or val == 'f'
 
or val == 'f'
 +
or val == 'off'
 
or tonumber(val) == 0
 
or tonumber(val) == 0
 
then
 
then

Aktuelle Version vom 10. April 2018, 17:42 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Yesno/Doku erstellt werden

-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.

return function (val, default)
	-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
	-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
	-- following line.
	val = type(val) == 'string' and val:lower() or val
	if val == nil then
		return nil
	elseif val == true 
		or val == 'yes'
		or val == 'y'
		or val == 'true'
		or val == 't'
		or val == 'on'
		or tonumber(val) == 1
	then
		return true
	elseif val == false
		or val == 'no'
		or val == 'n'
		or val == 'false'
		or val == 'f'
		or val == 'off'
		or tonumber(val) == 0
	then
		return false
	else
		return default
	end
end

Spenden-Adressen:
Bitcoin Icon BTC: 1EoecgUZnAjamUYaKstqwbremQqbucTaoZ
Ethereum Icon ETH: 0x0D2Ab63dfe70a7fA12f9d66eCfEA9dDc8F5173A8
XEM Icon XEM: NBZPMU-XES6ST-ITEBR3-IHAPTR-APGI3Y-RAAMHV-VZFJ
Verge Icon XVG: DGYmzxoe3ryK6MnsR13GqR9r1NThpxPcKs