跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
116
条目
154
文件
3
用户
730
编辑
Unimage Wiki
游戏内
武器
装备
剧情书
特殊道具
食物
特殊页面
实体
大型头目
强化头目
NPC
敌对生物
游戏流程
流程梗概
攻略
游戏难度
地区
进度
世界观
剧情资料
人物
大时间轴
创作历程
打开/关闭外观设置菜单
无法加载偏好设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
讨论
贡献
创建账号
登录
编辑“︁
模块:Dev/Yesno
”︁
来自Unimage Wiki
查看
阅读
编辑源代码
查看历史
associated-pages
模块
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
-- 来源:https://dev.fandom.com/wiki/Module%3AYesno -- 许可:CC BY-SA,作者与修订记录见来源页面 -- <nowiki> --- Yesno module for processing of boolean-like wikitext input. -- -- It works similarly to the [[wikipedia:Template:Yesno|Yesno Wikipedia -- template]]. This module is a consistent Lua interface for wikitext -- input from templates. -- -- Wikitext markup used by MediaWiki templates only permit -- string parameters like `"0"`, `"yes"`, `"no"` etc. As Lua -- has a boolean primitive type, Yesno converts this -- wikitext into boolean output for Lua to process. -- -- @script yesno -- @release stable -- @author [[User:Dessamator|Dessamator]] -- @attribution [[wikipedia:User:ATDT|ATDT]] -- @attribution [[wikipedia:User:Mr. Stradivarius|Mr. Stradivarius]] -- @attribution [[wikipedia:Special:PageHistory/Module:Yesno|Other Wikipedia contributors]] -- @see [[wikipedia:Module:Yesno|Original module on -- Wikipedia]] -- @see [[Module:Yesno/testcases|Test cases for this -- module]] -- @param {?boolean|string} value Wikitext boolean-style -- or Lua boolean input. -- * Truthy wikitext input (`'yes'`, `'y'`, `'1'`, -- `'t'` or `'on'`) produces `true` as output. -- * The string representations of Lua's true -- boolean value (`'true'`) also produces `true`. -- * Falsy wikitext input (`'no'`, `'n'`, `'0'`, -- `'f'` or `'off'`) produces `false` as output. -- * The string representation of Lua's false -- boolean value (`'false'`) also produces `false`. -- * Localised text meaning `'yes'` or `'no'` also -- evaluate to `true` or `false` respectively. -- @param[opt] {?boolean|string} default Output to return if -- the Yesno `value` input is unrecognised. -- @return {?boolean} Boolean output corresponding to -- `val`: -- * The strings documented above produce a -- boolean value. -- * A `nil` value produces an output of `nil`. -- As this is falsy, additional logic may be needed -- to treat missing template parameters as truthy. -- * Unrecognised values return the `default` -- parameter. Blank strings are a key example -- of Yesno's unrecognised values and can evaluate -- to `true` if there is a default value. local lower = mw.ustring.lower local msg = mw.message.new local yes = lower(msg('htmlform-yes'):plain()) local no = lower(msg('htmlform-no'):plain()) local en_yes = lower(msg('htmlform-yes'):inLanguage('en'):plain()) local en_no = lower(msg('htmlform-no'):inLanguage('en'):plain()) return function(value, default) value = type(value) == 'string' and lower(value) or value if value == nil then return nil elseif value == true or value == yes or value == en_yes or value == 'y' or value == 'true' or value == 't' or value == 'on' or value == 'enable' or tonumber(value) == 1 then return true elseif value == false or value == no or value == en_no or value == 'n' or value == 'false' or value == 'f' or value == 'off' or value == 'disable' or tonumber(value) == 0 then return false else return default end end -- </nowiki>
摘要:
请注意,所有对Unimage Wiki的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Unimage Wiki:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
该页面使用的模板:
模块:Dev/Yesno/doc
(
编辑
)
编辑“︁
模块:Dev/Yesno
”︁
来自Unimage Wiki