Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Neighbors
Esassani
Mobai
Glenn
Mors
Creatures
Fish
Insects
Shore-Dwellers
Search
Search
English
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Yesno
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- <nowiki> -- Source: https://genshin-impact.fandom.com/wiki/Module:Yesno --- 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>
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Petit Planet:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Template used on this page:
Module:Yesno/doc
(
edit
)