Content deleted Content added
Undid revision 887015946 by Kerry Raymond (talk) oops, wrong page |
|||
Line 107:
The following points may be worth noting when using templates:
* An unnamed parameter cannot contain an ordinary equals sign, as this would be interpreted as setting off a named parameter.{{efn|This does not apply if the equals sign comes within another template call or other item which the parser handles separately.}} To pass an equals sign in an unnamed parameter (for example in a [[URL]] with [[attribute–value pair]]s), replace the equals sign with the special template {{tlx|{{=}}}}, which returns an equals sign that will not be interpreted. Another method is to replace the unnamed parameter (and any subsequent unnamed parameters) with named parameters—the first unnamed parameter is equivalent to a named parameter {{para|1}} and so on. To call template {{tlx|done}} with <code>a=b</code> as the literal value for the first parameter, type either <code><nowiki>{{done|a{{=}}b}}</nowiki></code> or <code><nowiki>{{done|1=a=b}}</nowiki></code>.
* Similarly, it is not possible to use an ordinary pipe character <code>|</code> in template parameters, as it will be interpreted as a separator.{{efn|Again, this does not apply if it comes within another separately parsed item, such as a piped wikilink.}} This time, the problem can be solved by using the [[mw:Help:Magic words#Other|magic word]] {{tlx|!}} in place of the pipe, or—if the pipe is not intended to be parsed at a higher level—using the [[List of XML and HTML character entity references|HTML entity]] <code>&#124;</code>. Alternatively, for embedding [[Help:Tables|wikitables]] in templates, you may use {{tlx|Wikitable}} to avoid excessive {{tlx|!}}.
* Remember that whitespace characters (spaces, tabs, carriage returns, and line feeds) are not automatically stripped from the start and end of unnamed parameters, unlike with named parameters. Including such characters (or any other non-visible characters in any parameters) may in some cases affect the template's behaviour in unexpected ways. (Template designers can use {{tlx|Strip whitespace}} to remove unwanted whitespace in unnamed parameters.)
* In documentation and discussions, it is often convenient to be able to produce the template call syntax with a link to the template in question, but without actually calling the template. This can be done easily using the {{tlx|tl}} template (the "'''t'''emplate '''l'''ink" template). For example, {{tnull|tl|Example}} produces {{tl|Example}}. There are multiple other [[Template:Template-linking templates|template-linking templates]] available with different functionalities.
|