Template:Ifsubst: Difference between revisions
From All Skies Encyclopaedia
imported>RussBot m (Robot: moving pages out of redirected category) |
imported>Amalthea (New, more useful version, using safesubst.) |
||
Line 1: | Line 1: | ||
{{ {{{|safesubst:}}}#ifeq:{{ {{{|safesubst:}}}NAMESPACE}}|{{NAMESPACE}}|{{{1|}}}|{{{2|}}} }}<noinclude> |
|||
<!--Start building conditional: |
|||
{{Documentation|content= |
|||
--->{{#<!-- |
|||
--->{{<includeonly>subst:</includeonly>#if:||i}}f:<!-- |
|||
--->{{<include<!-- |
|||
--->{{<includeonly>subst:</includeonly>#if:||only}}><!-- |
|||
--->subst:</include<!-- |
|||
--->{{<includeonly>subst:</includeonly>#if:||only}}><!-- |
|||
--->Empty template|.}}<!-- |
|||
--->|<!--(else)-->{{{else|{{{2|}}}}}}<!-- |
|||
--->|<!--(then)-->{{{then|{{{1|}}}}}}}}<noinclude> |
|||
<pre>{{subst:ifsubst|then|else}}</pre> |
|||
===Usage=== |
|||
Add the above code to a template to give it <code>ifsubst</code> functionality. Note that this template in itself must actually be substituted into your new one, becoming part of its code. |
|||
Meta template that returns the first parameter if evaluated during substitution, and the second parameter if evaluated during transclusion.<br>Note that this template must be used in [[meta:Help:Safesubst|safesubst]] mode to work properly: |
|||
When the template to which this code has been added is then substituted, the "then" text will appear, else the "else" text. |
|||
:<code><nowiki>{{ {{{|safesubst:}}}ifsubst| yes | no }}</nowiki></code> |
|||
<!--Categories--> |
<!--Categories--> |
||
[[Category:Wikipedia |
[[Category:Wikipedia metatemplates|{{PAGENAME}}]] |
||
}} |
|||
<!--Other languages--> |
|||
[[vi:Tiêu bản:Ifsubst]] |
|||
</noinclude> |
</noinclude> |
Revision as of 09:05, 29 April 2010

Usage
Meta template that returns the first parameter if evaluated during substitution, and the second parameter if evaluated during transclusion.
Note that this template must be used in safesubst mode to work properly:
{{ {{{|safesubst:}}}ifsubst| yes | no }}