English Français Deutsch

Multiple lines in templates

Templates allow you to specify all arguments in line or in multiple lines, as the separator is the pipe character. This allows you to write the arguments for a template in a comprehensive way, especially for the query function. Newlines are automatically removed

However this can be a problem if you want to have more than one line within an argument. You will have the same problem if you have more than one line within a table cell. Adding a newline breaks the table syntax.

Say we have a template like

<table border=1>
<tr><td valign=top>{{{1}}}</td><td valign=top>...{{{2}}}...</td></tr>
<table>

Normally, the inline newline gets removed when you use it in the template:

{{table
| first cell
| first line 
second line
}}


first cell ...first line
second line...

To add newlines, use explicitely <br>.

{{table
| first cell
| first line 
<br>second line
}}


first cell ...first line

second line...

Or use the :: modifier to get the inline newlines untouched

{{table
| first cell
|:: first line 
second line
}}


first cell ...
first line

second line

...

You see that the arguments are not trimmed, which may be a problem in some cases. To remove that, do not use any spaces after :: and before }}

{{table
| first cell
|::first line 
second line}}


first cell ...

first line
second line

...

Pipes in links within templates are protected

{{table
| first cell
|::first line 
second line}}


first cell ...

first line alternate text
second line

...

Note that multiple lines are possible and the BR tag is not needed

{| border = 1
|-
| first cell
| first line
second line
|}

first cell first line
second line