Template talk:Yesno

Simplify
Can we simplify this template a bit? It seems that the second parameter is always "yes". &mdash; Martin (MSGJ · talk) 08:48, 1 May 2009 (UTC)
 * Is it? I remember we changed some (most?) of the defaults in WPBM to 'yes', but I can't remember if we got them all. And of course we'd need to check that no other templates are using this... good luck with that!! :D Happy‑melon 10:20, 2 May 2009 (UTC)
 * I reckon (hope) no one else is using it yet. I'll double check, but I think all defaults should be yes. I got a little bit confused, as always, with the ¬, but I it's not affecting that. I noticed that you hadn't added yesno to the hooks yet, so I'll do that as well. Cheers, &mdash; Martin (MSGJ · talk) 14:14, 2 May 2009 (UTC)

Docs
I have, I hope, clarified the documentation. Rich Farmbrough, 22:55, 31 August 2009 (UTC).

Negation
! is fairly standard as is ~, - and '. Rich Farmbrough, 09:06, 1 September 2009 (UTC).

¬?
What is ¬ used for in this template? PC78 (talk) 15:41, 7 October 2009 (UTC)
 * Nothing. But, as always, it's important that a value of ¬ is passed through to the next level unaltered.  Happy ‑ melon  17:09, 7 October 2009 (UTC)
 * Recent discussions with Martin have left me a little unsure with regards to using yesno, particuarly where I've been using it at WPBiography/sandbox. Are these changes good, or am I better using yesno within an #if statement? That banner does some pretty funky stuff if I enter ¬ as a value for some parameters, ¬ for example, or ¬ which triggers the a&e-work-group parameter instead. I'm not sure if these are things to be genuinely concerned about, but I'm thinking these issues stem from either this template or my (mis)use of it. PC78 (talk) 18:16, 7 October 2009 (UTC)
 * I think those edits look fine. Basically ¬ was chosen because it was assumed that no one would ever enter ¬ as a parameter value. It is generally used to determine whether a parameter has been defined or not. For example produces  because  is not defined. &mdash; Martin (MSGJ · talk) 18:59, 7 October 2009 (UTC)
 * Those edits are very clever, and to be fully supported and encouraged. As Martin says, no one should ever be consciously setting a parameter to ¬; for our purposes, "¬" === "undefined", and (most importantly) an 'undefined' that stays undefined when passed through to subtemplates.   Happy ‑ melon  22:27, 9 October 2009 (UTC)

Thought
Could/should yesno interpret ? as a null parameter? PC78 (talk) 01:04, 14 October 2009 (UTC)
 * That sounds like a sensible idea. And what about "yes/no" as well. &mdash; Martin (MSGJ · talk) 11:33, 14 October 2009 (UTC)
 * Probably. I've seen it used. PC78 (talk) 12:06, 14 October 2009 (UTC)
 * Could maybe copy some other ideas from Template:WPBannerMeta/bchecklist/b as well, e.g. "fail" for no. &mdash; Martin (MSGJ · talk) 12:25, 14 October 2009 (UTC)
 * Sounds like a plan. All of those would be valid for things other than B checks.  Only danger I can think of would be things like A-Class, but I don't think we use yesno there, do we?  Happy ‑ melon  13:28, 14 October 2009 (UTC)
 * Add ??? to the list. PC78 (talk) 01:23, 16 October 2009 (UTC)

Would it not be simpler and more logical to change the default from "yes" to "no"? PC78 (talk) 14:17, 31 October 2009 (UTC)
 * No, there are lot of banners that overload note parameters with, eg, dates (20 July 2009, etc), these wouldn't be recognised. IIRC the default of this template was no, but was changed after we realised that...  Happy ‑ melon  19:09, 31 October 2009 (UTC)
 * Why would such parameters need to use yesno, though? PC78 (talk) 19:47, 31 October 2009 (UTC)
 * Because they're mapped to note # parameters in WPBM: the parameter is overloaded to both trigger the note by its presence, and to contain information that the note uses.  Happy ‑ melon  19:54, 31 October 2009 (UTC)

So young and so much desired?
Just for curiosity: how can this new Template (1 yr now) be so multi-used (~3mln?). Was there a predecessor? Just curious. -DePiep (talk) 01:04, 10 July 2010 (UTC)
 * It was spun out from, which already had several million transclusions; by being integrated into that template, it gained most of its transclusions immediately. Happy ‑ melon  22:48, 10 July 2010 (UTC)

Purpose
At the risk of sounding stupid, why is this template needed? Why not just type in "yes" or "no"? D O N D E groovily  Talk to me  04:14, 4 January 2011 (UTC)
 * This is a normalisation template: it maps several different inputs into one output, thereby increasing standardisation. It's only "needed" in the same way that the templates it calls are 'needed': you could do away with them too and write the table code directly onto the page; but that would be a silly idea, because it would a) result in less standardisation, b) increase the amount of work each user would need to do to use the downstream page, and c) increase the size of the code on that downstream page.  Like all templates, this one serves to encapsulate functionality which is used in many places so it can be easily called upon when needed. Happy‑melon 15:29, 4 January 2011 (UTC)

def and blank
If blank is undefined but def is defined and the input is blank, should the output be def? &mdash; Martin (MSGJ · talk) 20:00, 28 March 2011 (UTC)
 * No, obviously. Fallback from blank to no does make sense.  As blank is the companion of no, and def is the companion of yes, we should not fallback to the opposite companion. --Ans (talk) 12:15, 5 June 2020 (UTC)

Use on values which include ref tags
Template:Yesno/testcases is an example of a problem

I tried to use this template in Infobox software license to conditionally include categories. I ran into a problem with WTFPL which contains this code:.

Specifically,  returns the default of "yes." I could change the default to "no," but then  would also return no.

Can someone identify a way to fix this? – Pnm (talk) 21:59, 10 January 2012 (UTC)


 * Fundamentally,  is not , so it's debatable whether anything is, per se, "broken"!  But omitting refs from consideration is a perfectly reasonable new feature request.  Unfortunately, bar using some of the godawful string functions to pick out the first couple of characters, there isn't really any way of doing this, AFAIK.  And given how deeply this template is buried in a lot of other callstacks, incorporating string functions into it would most likely massacre the performance of a huge range of templates.  Happy‑melon 22:19, 10 January 2012 (UTC)


 * Using str letter/trim I got it working in Template:Yesno/sandbox. Sounds like that wouldn't be a good way to fix it here, is that right? – Pnm (talk) 22:23, 10 January 2012 (UTC)


 * Established at Template:Yesno2 until the problem can be fixed here. – Pnm (talk) 22:39, 10 January 2012 (UTC)

Null or nullstring
Comments in the source scode says: ... |0       =  |         = ...

I think the returned value is not Null (like U+0000 or ASCII 0x00 really?), but "Nullstring" (zero length string, sometimes called a "Blank"). -DePiep (talk) 13:19, 27 June 2012 (UTC)
 * I suppose you are correct, but it is worth changing? &mdash; Martin (MSGJ · talk) 14:30, 27 June 2012 (UTC)
 * No ;-), or combine it with a next material edit. It's just checking my own knowledge. -DePiep (talk) 15:22, 27 June 2012 (UTC)

Most-used values
I've been thinking about which values of this template are actually the most used, after the discussion at WP:VPT and Wikid77's proposed yesno/sandbox2. This version assumes that the "yes" and "no" values are most used, and therefore should be highest in the switch statement, but I don't think this is necessarily the case. When a template like WikiProject United States is transcluded, the vast majority of the parameters checked with yesno aren't specified at all, so the "¬" value may actually be the most used in the yesno switch. I think the rest are probably, in order, "yes", the blank value, "no", "y", "n", "1", and "0". However, it would be good to get some actual numbers to work out the most efficient order. Does anyone have any ideas on how this could be done? — Mr. Stradivarius  ♪ talk ♪ 13:26, 24 March 2013 (UTC)
 * D'oh, that's not right at all, is it... if the user doesn't specify a parameter, then the value passed to yesno will be blank, not "¬". So then the order would be blank, "yes", "no", "y", "n", "1", "0", and "¬". Still, that's still slightly different from the order in sandbox2. — Mr. Stradivarius  ♪ talk ♪ 21:24, 24 March 2013 (UTC)
 * And then again, looking at WPBannerMeta, the yesno instances there mostly have the form, which means that "¬" might be the most-used anyway. It goes to show that we should do a proper analysis before changing the template. Also, this situation may change it WPBannerMeta gets rewritten using Lua, which could happen in the conceivably close future. One question that could help resolve this: which templates, other than WPBannerMeta, is Yesno used in the most? Analysing those invocations first may be the fastest way to determine the actual most-used values. — Mr. Stradivarius on tour  ♪ talk ♪ 02:59, 25 March 2013 (UTC)

Switch to lua
Hi please switch the template to Module:Yesno please 176.250.150.202 (talk) 18:15, 28 February 2014 (UTC)
 * That's a bad idea - the code for the module does a slightly different thing than the code for the template, so switching would end up breaking millions of pages. Also, because there is an initial overhead incurred by starting up Lua, and because the template code for this template is so simple, doing so would actually be slower than the current setup. — Mr. Stradivarius on tour  ♪ talk ♪ 21:39, 28 February 2014 (UTC)

Support true/false?
Should this template support "true" for yes and "false" for no? Those are pretty standard Boolean values in most programming languages. I've mocked it up [//en.wikipedia.org/w/index.php?title=Template:Yesno/sandbox&oldid=650948088 here]. --Ahecht (<span style="color:#FFF;background:#00f;display:inline-block;padding:1px 1px 0;vertical-align:-0.3em;line-height:1;font-size:62.5%;text-align:center;">TALK PAGE ) 22:46, 3 March 2015 (UTC)

Since there was no objection to my proposal for 4 months, I formally propose adding true and false per the [//en.wikipedia.org/w/index.php?title=Template:Yesno/sandbox&oldid=650948088 sandbox].

Ahecht (<span style="color:#FFF;background:#00f;display:inline-block;padding:1px 1px 0;vertical-align:-0.3em;line-height:1;font-size:62.5%;text-align:center;">TALK PAGE ) 14:18, 2 July 2015 (UTC)
 * ✅ &mdash; Martin (MSGJ · talk) 14:46, 2 July 2015 (UTC)

Support on/off
This should test for those values, too. A discussion at Template talk:As of indicates that some people prefer and have been using these values, so any attempt to add a YesNo test to such templates, to provide additional functionality, will fail for any instances using "on" or "off". We basically have no idea how many that is, but it's a trivial fix to add them here. — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼  23:40, 27 November 2015 (UTC) — SMcCandlish ☏ ¢ &gt;ʌⱷ҅ᴥⱷʌ&lt;  10:43, 11 December 2017 (UTC)
 * Red information icon with gradient background.svg Not done: I don't see a consensus there for adding "on" and "off" here in that discussion. Considering that this template is used on millions of pages, and often multiple times per page, we should make sure that there is a need to add more parameters before potentially slowing down the time this template takes to render. An alternative might be to add "on" and "off" as aliases in Template:As of if it is popular in that template in particular. Alternatively, if you want to find out how many uses there are, adding a tracking category to Template:As of can do that easily. — <span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius  ♪ talk ♪ 02:51, 28 November 2015 (UTC)
 * Over two years with no substantive objection, so I'm reopening this. The code is in Template:Yesno/sandbox, tested at bottom of Template:Yesno/testcases (produces same output with on/off as it does with yes/no, etc.). It's not just about ; a lot of templates use on/off, and some of them need this logic. If this isn't implemented here, I could just fork a  to resolve it, but WP:TFD will merge them later, so may as well do it right the first time.  Lack of this has been holding up fixing  (it is documented with and thus is mostly deployed with on) which has long been ungrammatically leaving out punctuation by default, when it needs to do the opposite and use commas unless told not to for some context-specific reason (e.g. to save space in a very tight table, or to mimic the exact formatting material in a quotation). I have the fixed version at  now, but  does not work.  The alternative would be to re-do the entire template in much more bletcherous code that doesn't use, but that defeats the purpose of having .  More to the point, the purpose of  is to parse all the common positive/negative inputs people use. On/off is among those, and was just left out as an oversight.  Adding a single additional pair of yes/no tests to the switch has no measurable impact on performance. Some of our templates have 100+ cases to test for; two long ones (not quite that long) I've worked on are Template:S-rail/lines and Template:Single chart, neither of which cause any problems for anyone.
 * Red information icon with gradient background.svg Not done for now: There was an objection two years ago. (Whether you call it substantive is subjective.) And you still haven't shown consensus for this change. &mdash; Martin (MSGJ · talk) 12:23, 12 December 2017 (UTC)
 * Fine, I'll just RfC it, but please see WP:EDITING and WP:NOT and WP:CONSENSUS policies. Lack of non-addressed objections constitutes consensus to proceed, or WP would have virtually no content of any kind and would have failed the month it opened.  — SMcCandlish ☏ ¢ &gt;ʌⱷ҅ᴥⱷʌ&lt;  21:23, 12 December 2017 (UTC)
 * Re-enabling edit request, per RfC below.  — SMcCandlish ☏ ¢ 😼  06:25, 23 January 2018 (UTC)
 * Yes check.svg Done &mdash; Martin (MSGJ · talk) 08:37, 23 January 2018 (UTC)

YesNo-Yes and YesNo-No wrappers
A while back, I created wrapper templates, and, for the two most commonly used sets of parameters: those to return "yes" unless an explicit negative value is provided, and the opposite. Forgot to mention it here. — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼  23:44, 27 November 2015 (UTC)

Support on/off detection
<div class="boilerplate" style="background-color: #EDEAFF; padding: 0px 10px 0px 10px; border: 1px solid #8779DD;">
 * The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Should this template support the common  binary options in addition to the rest it already handles?  — SMcCandlish ☏ ¢ &gt;ʌⱷ҅ᴥⱷʌ&lt;  21:23, 12 December 2017 (UTC)


 * Yes, obviously. 1) the  of the template is to perform this simple test function for such binary pairs, 2) it's only missing this pair out of all common variants; 3) multiple use cases have been provided for this; 4) no actually substantive objections have been raised in over two years, and the iffy ones that were raised back-when have already been addressed; 5) the lack of it is holding up actual work; 6) if this template were not (possibly unnecessarily) full-protected, this would have already been implemented a long time ago; 7) it's just going to be implemented in a side template and merged in later if not done the obvious and direct way.  — SMcCandlish ☏ ¢ &gt;ʌⱷ҅ᴥⱷʌ&lt;  21:23, 12 December 2017 (UTC)
 * Yes, also obviously The point of the template (this is my first exposure to it) seems to be to reduce a variety of boolean results to a predictable output. So then, I would seriously consider trying to include every possible binary pair (meaning those likely to be used in code, of course. Male/female isn't one I think would be very useful). Of course, if it turns out I'm mistaken about the purpose (or if it's actually put to some different use), then I might change my mind. ᛗᛁᛟᛚᚾᛁᚱPants   Tell me all about it.  07:14, 23 December 2017 (UTC)
 * Is on yes or on no? --Izno (talk) 20:30, 4 January 2018 (UTC)
 * Given that 1 = on and 0 = off in binary and 1 = yes and 0 = no in this template, this is a self-answering question. :-)  — SMcCandlish ☏ ¢ &gt;ʌⱷ҅ᴥⱷʌ&lt;  08:36, 7 January 2018 (UTC)
 * If on/off support is added here, then it should also be added to Module:Yesno. The one objection against adding it here was raised by on performance grounds. Is there any estimate for the overall decrease in performance that will result from the addition of this extra capability? – Uanfala (talk) 04:44, 5 January 2018 (UTC)
 * It's a non-argument, or we wouldn't have templates that do anything like this at all. Already addressed this in the original thread: "Adding a single additional pair of yes/no tests to the switch has no measurable impact on performance. Some of our templates have 100+ cases to test for; two long ones (not quite that long) I've worked on are Template:S-rail/lines and Template:Single chart, neither of which cause any problems for anyone." They do it in less than the blink of an eye. And yes, it also needs to be added to the module, which is even more efficient.  Why is this template not already calling the module?  — SMcCandlish ☏ ¢ &gt;ʌⱷ҅ᴥⱷʌ&lt;  08:39, 7 January 2018 (UTC)
 * Of course it will all appear like "a blink of an eye" in either case. I was just asking what the cumulative effects would be, and giving a chance for the original objection to this proposal to be articulated in more concrete terms. Why is this template not already calling the module? – see . – Uanfala (talk) 15:20, 7 January 2018 (UTC)


 * The discussion above is closed. <b style="color: #FF0000;">Please do not modify it.</b> Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Protected edit request on 22 February 2019
Please add <noinclude ></noinclude> to this template as I have nominated it for merging. &#123;&#123;3x&#124;p&#125;&#125;ery (talk) 19:05, 22 February 2019 (UTC)
 * ❌ Added to doc, but no need to cause that much server load (11 million + pages..) for a notice displayed only on this page. Galobtter (pingó mió) 19:18, 22 February 2019 (UTC)

Protected edit request on 3 June 2020
Please add  parameter as shown here, so we can simply write   rather than   --Ans (talk) 03:33, 3 June 2020 (UTC)
 * Pictogram voting question.svg Question: why would you use "else" as a fallback for "yes"? Also, unless you are using the esoteric ¬ (which has very limited use) you can use just "no" as a fallback for blank. &mdash; Martin (MSGJ · talk) 09:23, 3 June 2020 (UTC)
 * Since, in addition to, we sometimes also need   which is equivalent to.
 * Note: My diff link has been updated to fix my bug --Ans (talk) 12:15, 3 June 2020 (UTC)
 * I would like to see a use-case, a situation in which the proposed change would be beneficial, where it would simplify matters. -- Red rose64 &#x1f339; (talk) 22:37, 3 June 2020 (UTC)
 * So we can use  or   like we ever did with Template:Ifyes and Template:Ifno respectively. --Ans (talk) 07:24, 5 June 2020 (UTC)
 * But where would this be used? -- Red rose64 &#x1f339; (talk) 18:15, 5 June 2020 (UTC)
 * Red information icon with gradient background.svg Not done for now: please establish a consensus for this alteration before using the template. Izno (talk) 01:51, 5 June 2020 (UTC)

Protected edit request on 24 August 2020
Please add "t" and "f" as alternative forms of "true" and "false", respectively. AntiCompositeNumber (talk) 18:16, 24 August 2020 (UTC)
 * This seems appropriate given Module:Yesno already supports them. Nardog (talk) 18:24, 24 August 2020 (UTC)
 * ❌ (not yet) - this needs to be worked up in the sandbox and tested first. — xaosflux  Talk 19:57, 25 August 2020 (UTC)
 * to the sandbox, request reactivated. * Pppery * <sub style="color:#800000">it has begun... 02:17, 26 August 2020 (UTC)
 * ✅ - of course any admin should revert without delay if unforseen issues are caused. — xaosflux  Talk 03:16, 28 August 2020 (UTC)

Suggestion
On Template:Yesno-yes which outputs "yes" to everything not explicitly false, the options for blank, def and ¬ should probably fall back to so the syntax would be shorter. The code for this is on the /sandbox now. &mdash; Martin (MSGJ · talk) 23:08, 19 November 2020 (UTC)
 * I one hundred percent agree but that's never gonna happen. Making sure noting breaks after such a change would require massive work considering the 500000 transclusions. When I merged if affirmed here with a fraction of the transclusions it took a long time with quite sophisticated queries to make sure nothing broke and even then I managed to temporarily break some signpost templates. --Trialpears (talk) 23:40, 19 November 2020‎ (UTC)
 * Well never say never ... but I take the point that the costs seem to outweigh the advantages. The other thing I don't like about this template, is that defaults to "no". No doubt that suited the purpose of the editor who created it originally, but it is a little incongruous with the default behaviour of the main template where  defaults to blank. &mdash; Martin (MSGJ · talk) 12:20, 23 November 2020 (UTC)
 * I think that the intent was to return an explicit value whichever, rather than an explicit "yes" and implicit "no". This difference was recognised as long ago as the 1830s when the Great Western Railway decided to signal their trains by means of green or red flags (later replaced by boards) instead of using a flag for "danger" and an absence of a flag for "all right", as other railways did. -- Red rose64 &#x1f339; (talk) 21:53, 23 November 2020 (UTC)
 * I've created Template:Yesno-yes/fallback, which implements this. Tol  (talk &#124; contribs) @ 00:36, 19 November 2021 (UTC)
 * Is there a better alternative that achieves the functionality of Martin/MSGJ's proposal than this?
 * Daask (talk) 21:37, 7 June 2024 (UTC)
 * Daask (talk) 21:37, 7 June 2024 (UTC)

Clear yes or no (request for Template:Either yes or no)
If you put  instead of , the template will work better or at least more intuitive (with clear yes or no).

I suggest making template Either yes or no (with this title instead of 'yes/no' because yes/no already exists as redirect to yesno; instead of title 'Either yes or no' can be other title if more appropriate) for this purpose, with same source code except the change suggested above; there are cases when this is needed, simplifying the code (e.g. #if: or additional parameters not needed in such cases). --5.43.72.55 (talk) 04:06, 10 December 2020 (UTC)

Template:yesno-yes
I think yesno-yes can be redirected to this template (yesno). It currently contains transclusion of yesno with some substing but has yesno's documentation and talk page redirecting to yesno's talk page. If not same, documentation should be made for yesno-yes to explain where it's different from yesno (and separate talk page enabled by removing redirect to this talk page). --109.163.168.201 (talk) 19:29, 12 December 2020 (UTC)
 * It's a wrapper for this template. There is some information in "Comparison with related templates" on the doc page. &mdash; Martin (MSGJ · talk) 19:31, 12 December 2020 (UTC)

Incorrect results when substituting with #if
Due to the  comments that are the defaults for the  parameter, the template ends up giving incorrect results when substed inside a substed #if for the "no" and "blank" cases. This is due to the differing behaviour of  compared to. I don't know if the differing #if behaviour is intentional (in which case this template should be fixed by removing the  comments) or if it is is a bug in MediaWiki. GreenComputer (talk) 15:26, 28 December 2020 (UTC)
 * It's not a MediaWiki bug, it's expected behaviour. The  construct tests for whether the first argument is the empty string or not, and   is not an empty string, it is a valid HTML comment. -- Red rose64 &#x1f339; (talk) 18:06, 28 December 2020 (UTC)
 * Surely that would mean that the non-subst case  is buggy, as it currently results in "" despite the first argument containing a comment? GreenComputer (talk) 22:05, 28 December 2020 (UTC)

Protected edit request on 25 January 2021
This page is not necessarily true. Its skewing information to upsell a certain agenda 24.205.102.59 (talk) 07:20, 25 January 2021 (UTC)
 * Red information icon with gradient background.svg Not done: I think you're on the wrong page. This is an internal template that does not contain any encyclopedic information. --Trialpears (talk) 07:29, 25 January 2021 (UTC)