Module:Yesno: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
interwiki>Shirayuki k (Changed protection level for "Module:Yesno": High-risk module ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
k (1 versie geïmporteerd) |
(geen verschil)
|
Huidige versie van 25 sep 2019 om 13:46
Bestand:OOjs UI icon check-constructive.svg | This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
Bestand:Semi-protection-shackle-no-text.svg | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module handles "yes" and "no" options in templates.
-- 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