Template:!

From Octave
Revision as of 04:04, 30 November 2013 by Rezahousseini (talk | contribs)
Jump to navigation Jump to search

[edit]

Template-info.png Template Documentation

This is an auxiliary template allowing the encoding of | within template parameters, because the pipe character is normally interpreted as a separator. This template is necessary if the character is used in wiki table syntax, or if the parameter is automatically wikilinked and you wish to use a pipe to specify different link text from the target page name. In other cases it is better to use the {{pipe}} template.

This template cannot be used for putting the character as text in a wiki table; in that case, again, {{pipe}} can be used. See below for comparison between the two templates.

Note that no special template is needed for "!" (exclamation mark).

A simple example

The following template code for Template:Codeline using an ordinary pipe character,

  • {{Codeline|if (nargin > 2 || nargin < 5), print_usage; endif}}

produces:

  • if (nargin > 2

whereas this code using the {{!}} meta-template,

  • {{Codeline|if (nargin > 2 {{!}}{{!}} nargin < 5), print_usage; endif}}

produces:

  • if (nargin > 2 || nargin < 5), print_usage; endif

Comparison with {{pipe}}

{{pipe}} is not a duplicate of {{!}}. These are two different templates with very different functionality. {{pipe}} inserts the code &#124;, which does render as a pipe in the web browsers. But it does not interfere with the MediaWiki parser. Thus it can be used in text inside wikitables and parserfunctions without causing any altered function of them. {{!}} inserts an actual pipe character that is parsed by the MediaWiki parser. Thus it does have effect inside wikitables.

Basically, {{!}} is used to delay parsing by the pipe for one round so that a wikitable pipe can be placed inside and controlled by for instance an #if statement. If you are using the Code template, you will want to use {{!}}.