Template talk:!: Difference between revisions

From The Urban Dead Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
Line 1: Line 1:
==Documentation==
==Documentation==
This is an auxiliary template allowing one to encode "<code>|</code>"
If you want to display a pipe as plain text without it being parsed by the wiki, just use {{CodeInline|&amp;#124;}}, which can be used in wiki tables and inside template variables without any problems.
within template and parser function parameters. To get the symbol in final output this template is unnecessary, better use "<code>&amp;#124;</code>" which is rendered the same. Use this template in parameter values of [[help:templates|template]]s of which the result is used in [[help:tables|table]] syntax, since this requires the "real" pipe character.  


This template cannot be used for putting the character as text in a wiki table; in that case, again, "<code>&amp;#124;</code>" can be used.
If you need to put wiki table code into the variable of a template, you will need to replace your pipes with a call to this template like so {{CodeInline|<nowiki>{{!}}</nowiki>}}. This will prevent the wiki from thinking there are pipes separating one variable from another when you set up the template, but will become a "real" pipe when the template is called, meaning the wiki will then treat it as part of your table syntax. This is often used as a reult of selection templates such as {{tl|if}}, {{tl|ifdef}} and {{tl|ifndef}}.


Note that the table syntax code "<code>!</code>" (exclamation mark) can be used directly in parameter values, so for that a template like this is not needed.
For example, here we use {{tl|ifdef}} on two imaginary variables, the first is defined but the second is not. So only the first should appear in the table.
 
<pre>
{| style="border:1px solid black"
{{ifdef|x|2={{!}} style="color:red" {{!}} If you see me, the first variable is defined.}}
|-
{{ifdef||2={{!}} style="color:blue" {{!}} If you see me, the second variable is defined.}}
|}
</pre>
 
The result:
{| style="border:1px solid black"
{{ifdef|x|2={{!}} style="color:red" {{!}} If you see me, the first variable is defined.}}
|-
{{ifdef||2={{!}} style="color:blue" {{!}} If you see me, the second variable is defined.}}
|}

Latest revision as of 01:46, 22 September 2010

Documentation

If you want to display a pipe as plain text without it being parsed by the wiki, just use &#124;, which can be used in wiki tables and inside template variables without any problems.

If you need to put wiki table code into the variable of a template, you will need to replace your pipes with a call to this template like so {{!}}. This will prevent the wiki from thinking there are pipes separating one variable from another when you set up the template, but will become a "real" pipe when the template is called, meaning the wiki will then treat it as part of your table syntax. This is often used as a reult of selection templates such as {{if}}, {{ifdef}} and {{ifndef}}.

For example, here we use {{ifdef}} on two imaginary variables, the first is defined but the second is not. So only the first should appear in the table.

{| style="border:1px solid black"
{{ifdef|x|2={{!}} style="color:red" {{!}} If you see me, the first variable is defined.}}
|-
{{ifdef||2={{!}} style="color:blue" {{!}} If you see me, the second variable is defined.}}
|}

The result:

If you see me, the first variable is defined.