Difference between revisions of "User:Ericb/Ifeq"

From MHWiki
m (better handling of matching empty strings)
m (link to live version)
 
Line 1: Line 1:
<noinclude>A conditional template.  The first two arguments must be simple names appropriate for named parameters of a template, or empty.  If they match, then this ends up calling the <nowiki>{{Use}}</nowiki> template with the indirect argument named twice, so the overall expansion is the second use of the indirect name, or the original third argument.  But if they differ, then this ends up using <nowiki>{{Use}}</nowiki> with the indirect argument named only once, so the overall expansion is the original fourth argument.
+
<noinclude>''This page was my playground before creating [[Template:Ifeq]]''
 +
 
 +
A conditional template.  The first two arguments must be simple names appropriate for named parameters of a template, or empty.  If they match, then this ends up calling the <nowiki>{{Use}}</nowiki> template with the indirect argument named twice, so the overall expansion is the second use of the indirect name, or the original third argument.  But if they differ, then this ends up using <nowiki>{{Use}}</nowiki> with the indirect argument named only once, so the overall expansion is the original fourth argument.
  
 
That is, this is an alternate implementation of {{#ifeq:test1|test2|if equal|if differ}}, with a slightly different syntax:<br/>
 
That is, this is an alternate implementation of {{#ifeq:test1|test2|if equal|if differ}}, with a slightly different syntax:<br/>
 
<nowiki>{{ifeq|test1|test2|if equal|if differ}}</nowiki>
 
<nowiki>{{ifeq|test1|test2|if equal|if differ}}</nowiki>
 
</noinclude><includeonly>{{User:Ericb/Use|indir=a{{{1|}}}|a{{{1|}}}={{{4|}}}|a{{{2|}}}={{{3|}}}}}</includeonly>
 
</noinclude><includeonly>{{User:Ericb/Use|indir=a{{{1|}}}|a{{{1|}}}={{{4|}}}|a{{{2|}}}={{{3|}}}}}</includeonly>

Latest revision as of 01:30, 26 October 2011

This page was my playground before creating Template:Ifeq

A conditional template. The first two arguments must be simple names appropriate for named parameters of a template, or empty. If they match, then this ends up calling the {{Use}} template with the indirect argument named twice, so the overall expansion is the second use of the indirect name, or the original third argument. But if they differ, then this ends up using {{Use}} with the indirect argument named only once, so the overall expansion is the original fourth argument.

That is, this is an alternate implementation of {{#ifeq:test1|test2|if equal|if differ}}, with a slightly different syntax:
{{ifeq|test1|test2|if equal|if differ}}