打开/关闭菜单
打开/关闭个人菜单
未登录
登录即可进行编辑

Module:Yesno:修订间差异

出自Tardis百科,中文神秘博士维基
添加的内容 删除的内容
(创建页面,内容为“-- Imported from: https://en.wikipedia.org/wiki/Module:Yesno -- 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 retu…”)
 
无编辑摘要
第20行: 第20行:
or val == '真'
or val == '真'
or val == '开'
or val == '开'
or val == '開'
or tonumber(val) == 1
or tonumber(val) == 1
then
then
第32行: 第33行:
or val == '假'
or val == '假'
or val == '关'
or val == '关'
or val == '關'
or tonumber(val) == 0
or tonumber(val) == 0
then
then

2024年5月25日 (六) 16:29的版本

可在Module:Yesno/doc创建此模块的帮助文档

-- Imported from: https://en.wikipedia.org/wiki/Module:Yesno

-- 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 val == '是'
		or val == '真'
		or val == '开'
		or val == '開'
		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 val == '否'
		or val == '假'
		or val == '关'
		or val == '關'
		or tonumber(val) == 0
	then
		return false
	else
		return default
	end
end
我们提供服务需要使用Cookie。您使用我们的服务,即表示您同意我们使用Cookie。