今天是2024年6月29日 第26周 星期六

代人,时大变了。

我们生活在大地上,但我们的梦想超越天空。

“模块:Yesno”的版本间的差异

来自Akarin
跳到导航 跳到搜索
(copy from en:Module:Yesno
 
(以“-- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) val...”为内容创建页面)
(没有差异)

2014年4月12日 (六) 23:14的版本

50px 模块文档[创建]
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
return function (val, default)
    val = type(val) == 'string' and mw.ustring.lower(val) or val -- put in lower case
    if val == nil then
        return nil
    elseif val == false or val == 'no' or val == 'n' or val == 'false' or tonumber(val) == 0 then
        return false
    elseif val == true or val == 'yes' or val == 'y' or val == 'true' or tonumber(val) == 1 then
        return true
    else
        return default
    end
end