| Template:Yesno ispermanentlyprotected from editing as it is aheavily used or highly visible template. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported byconsensus, editors may use {{edit protected}} to notify an administrator to make the requested edit. Usually, any contributor may edit the template'sdocumentation to add usage notes orcategories. Any contributor may edit the template'ssandbox. Functionality of the template can be checked usingtest cases. |
Can we simplify this template a bit? It seems that the second parameter is always "yes". — Martin(MSGJ · talk)08:48, 1 May 2009 (UTC)[reply]
I have, I hope, clarified the documentation.RichFarmbrough,22:55, 31 August 2009 (UTC).[reply]
! is fairly standard as is ~, - and '.RichFarmbrough,09:06, 1 September 2009 (UTC).[reply]
What is ¬ used for in this template?PC78 (talk)15:41, 7 October 2009 (UTC)[reply]
|small=¬ for example, or|filmbio-work-group=¬ 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)[reply]Could/should{{yesno}} interpret ? as a null parameter?PC78 (talk)01:04, 14 October 2009 (UTC)[reply]
|A-Class=, but I don't think we use yesno there, do we?Happy‑melon13:28, 14 October 2009 (UTC)[reply]Would it not be simpler and more logical to change the default from "yes" to "no"?PC78 (talk)14:17, 31 October 2009 (UTC)[reply]
|afd=20 July 2009, etc), these wouldn't be recognised. IIRC the default of this templatewas no, but was changed after we realised that...Happy‑melon19:09, 31 October 2009 (UTC)[reply]|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‑melon19:54, 31 October 2009 (UTC)[reply]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)[reply]
{{WPBannerMeta}}, which already had several million transclusions; by being integrated into that template, it gained most of its transclusions immediately.Happy‑melon22:48, 10 July 2010 (UTC)[reply]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 me04:14, 4 January 2011 (UTC)[reply]
Ifblank is undefined butdef is defined and the input is blank, should the output bedef? — Martin(MSGJ · talk)20:00, 28 March 2011 (UTC)[reply]
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 withWTFPL which contains this code:OSI approved = No<ref>{{cite web|url=http://www.opensource.org/minutes20090304|title=OSI Board Meeting Minutes, Wednesday, March 4, 2009}}</ref>.
Specifically,{{yesno|No<ref>...</ref>}} returns the default of "yes." I could change the default to "no," but then{{yesno|Yes<ref>...</ref>}} would also return no.
Can someone identify a way to fix this? – Pnm (talk)21:59, 10 January 2012 (UTC)[reply]
No<ref>...</ref> isnotNo, 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 likelymassacre the performance of a huge range of templates.Happy‑melon22:19, 10 January 2012 (UTC)[reply]Comments in the source scode says:
... |0 = {{{no|<!-- null -->}}} | = {{{blank|{{{no|<!-- null -->}}}}}}...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)[reply]
I've been thinking about which values of this template are actually the most used, after the discussion atWP:VPT#Template:Yesno 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)[reply]
{{yesno|{{{parameter|¬}}}|¬=¬}}, 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)[reply]Hi please switch the template toModule:Yesno please176.250.150.202 (talk)18:15, 28 February 2014 (UTC)[reply]
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 uphere. --Ahecht (TALK
PAGE)22:46, 3 March 2015 (UTC)[reply]
Thisedit request has been answered. Set the|answered= parameter tono to reactivate your request. |
Since there was no objection to my proposal for 4 months, I formally propose adding true and false per thesandbox.Ahecht (TALK
PAGE)14:18, 2 July 2015 (UTC)[reply]
Thisedit request has been answered. Set the|answered= parameter tono to reactivate your request. |
This should test for those values, too. A discussion atTemplate 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)[reply]
It's not just about{{as of}}; 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{{Yesno2}} to resolve it, butWP:TFD will merge them later, so may as well do it right the first time. Lack of this has been holding up fixing{{Post-nominals}} (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{{post-nominals/sandbox}} now, but{{post-nominals/sandbox|comma=off}} does not work. The alternative would be to re-do the entire template in much more bletcherous code that doesn't use{{yesno}}, but that defeats the purpose of having{{yesno}}. More to the point, the purpose of{{yesno}} 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 areTemplate:S-rail/lines andTemplate:Single chart, neither of which cause any problems for anyone.
— SMcCandlish☏¢ >ʌⱷ҅ᴥⱷʌ< 10:43, 11 December 2017 (UTC)[reply]
A while back, I created wrapper templates,{{YesNo-Yes}} and{{YesNo-No}}, 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)[reply]
The consensus in this RfC is that this template should support the common
on/offbinary options in addition to the rest it already handles. Concerns were raised about performance which SMcCandlish has addressed. Concerns about cumulative effects on performance have been raised but nothing specific has been pointed out.
Should this template support the commonon/off binary options in addition to the rest it already handles? — SMcCandlish☏¢ >ʌⱷ҅ᴥⱷʌ< 21:23, 12 December 2017 (UTC)[reply]
Why is this template not already calling the module?– see#Switch to lua. –Uanfala (talk)15:20, 7 January 2018 (UTC)[reply]
Thisedit request has been answered. Set the|answered= parameter tono to reactivate your request. |
Please add<noinclude>{{subst:tfm|If affirmed}}</noinclude> to this template as I have nominated it for merging.{{3x|p}}ery (talk)19:05, 22 February 2019 (UTC)[reply]
Thisedit request has been answered. Set the|answered= parameter tono to reactivate your request. |
Please add{{{else}}} parameter as shownhere, so wecan simply write{{yesno|{{{1}}}|yes=123|else=456}} rather than{{yesno|{{{1}}}|yes=123|no=456|blank=456|¬=456|def=456}} --Ans (talk)03:33, 3 June 2020 (UTC)[reply]
{{yesno|{{{1}}}|yes=123|else=456}}, we sometimes also need{{yesno|{{{1}}}|no=123|else=456}} which is equivalent to{{yesno|{{{1}}}|no=123|yes=456|blank=456|¬=456|def=456}}.{{yesno|yes=show this text|else=otherwise show this text}} or{{yesno|no=show this text|else=otherwise show this text}} like we ever did withTemplate:Ifyes andTemplate:Ifno respectively. --Ans (talk)07:24, 5 June 2020 (UTC)[reply]{{edit protected}} template.Izno (talk)01:51, 5 June 2020 (UTC)[reply]Thisedit request has been answered. Set the|answered= parameter tono to reactivate your request. |
Please add "t" and "f" as alternative forms of "true" and "false", respectively.AntiCompositeNumber (talk)18:16, 24 August 2020 (UTC)[reply]
OnTemplate:Yesno-yes which outputs "yes" to everything not explicitly false, the options for blank, def and ¬ should probably fall back to {{{yes}}} so the syntax would be shorter. The code for this is on the/sandbox now. — Martin(MSGJ · talk)23:08, 19 November 2020 (UTC)[reply]
{{yesno|{{yesno-yes|{{{1|}}}}}|yes=A|no=B}}}If you put|0 = {{{no|no}}} instead of|0 = {{{no|<!-- null -->}}}, 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)[reply]
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)[reply]
Due to the<!-- null --> comments that are the defaults for the{{{no}}} 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{{#if:<!-- comment -->|T|F}} compared to{{subst:#if:<!-- comment -->|T|F}}.
| Wikitext | Result | Result usingsandbox version without<!-- null --> comments |
|---|---|---|
{{#if:{{yesno|}}|T|F}} | F | F |
{{subst:#if:{{subst:yesno|}}|T|F}} | T | F |
{{#if:{{yesno|no}}|T|F}} | F | F |
{{subst:#if:{{subst:yesno|no}}|T|F}} | T | F |
{{#if:<!-- comment -->|T|F}} | F | |
{{subst:#if:<!-- comment -->|T|F}} | T | |
I don't know if the differing #if behaviour is intentional (in which case this template should be fixed by removing the<!-- null --> comments) or if it is is a bug in MediaWiki.GreenComputer (talk)15:26, 28 December 2020 (UTC)[reply]
{{#if:...}} construct tests for whether the first argument is the empty string or not, and<!-- comment --> is not an empty string, it is a validHTML comment. --Redrose64 🌹 (talk)18:06, 28 December 2020 (UTC)[reply]{{#if:<!-- comment -->|T|F}} is buggy, as it currently results in "F" despite the first argument containing a comment?GreenComputer (talk)22:05, 28 December 2020 (UTC)[reply]<!-- null --> instead of the empty string during substitution under certain circumstances (e.g. if|no= is undefined and the input is0), which could cause unexpected downstream behaviour? Is there a good reason for this difference between the substituted and unsubstituted cases?Theknightwho (talk)17:11, 16 November 2025 (UTC)[reply]| It isrequested that an edit be made to thefully protected template atTemplate:Yesno. (edit ·history ·last ·links ·sandbox ·edit sandbox ·sandbox history ·sandbox last edit ·sandbox diff ·test cases ·transclusion count ·protection log) This template must be followed by acomplete and specific description of the request, so that an editor unfamiliar with the subject matter could complete the requested edit immediately. Edit requests to fully protected pages should only be used for edits that are eitheruncontroversial or supported byconsensus. If the proposed edit might be controversial, discuss it on the protected page's talk pagebefore using this template. Consider making changes first to thetemplate's sandbox andtest them thoroughly here before submitting an edit request. To request that a page be protected or unprotected, make aprotection request. When the request has been completed or denied, please add the |
To remove the<!-- null --> comments, as these cause differences in behaviour between substitution and transclusion.
For example, the input{{yesno|0}} transcludes the empty string, since|no= has not been defined. On the other hand,{{subst:yesno|0}} substitutes the text<!-- null -->. The reason for this is because HTML comments are removed prior to template expansion during transclusion (e.g.{{{no|<!-- null -->}}} resolves to{{{no|}}}), but this isnot the case during substitution, where HTML comments are simply treated like any other text.
This is a problem, because that unexpected output of<!-- null --> can cause any number of downstream effects (e.g.{{#if:{{yesno|0}}|foo|bar}} transcludesbar, whereas{{subst:#if:{{subst:yesno|0}}|foo|bar}} substitutesfoo).
Diff:
| − | |0 = | + | |0 ={{{no|}}} | ={{{blank|{{{no|}}}}}} |
Theknightwho (talk)23:47, 16 November 2025 (UTC)[reply]
safesubst:? I don't see how what you've said makes any sense at all, so I'm reopening this.Theknightwho (talk)17:04, 19 November 2025 (UTC)[reply]