Editing Module:Yesno
From Emergency Response: Liberty County Wiki
More actions
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
-- |
-- Copied from https://www.mediawiki.org/wiki/Module:Yesno |
||
-- License: CC-BY-SA 4.0 |
|||
-- Function allowing for consistent treatment of boolean-like wikitext input. |
-- Function allowing for consistent treatment of boolean-like wikitext input. |
||
| Line 5: | Line 6: | ||
return function (val, default) |
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 |
|||
| ⚫ | |||
or tonumber(val) == 1 |
|||
| ⚫ | |||
| ⚫ | |||
elseif val == false |
|||
| ⚫ | |||
or val == 'no' |
|||
or val == 'n' |
|||
or val == 'false' |
|||
or val == 'f' |
|||
or val == 'off' |
|||
or tonumber(val) == 0 |
|||
| ⚫ | |||
or val == 'nein' |
|||
return false |
|||
or tonumber(val) == 0 |
|||
| ⚫ | |||
| ⚫ | |||
return default |
|||
| ⚫ | |||
| ⚫ | |||
return default |
|||
| ⚫ | |||
end |
end |
||