[Mediawiki-l] Tables, templates, "optional cells", and newlines

Kelvin Chung kelvSYC at shaw.ca
Mon Sep 21 23:45:42 UTC 2009


I have this weird thing with wiki syntax: Consider a template with  
"optional columns", like so:

{|
! Foo
{{#if: {{{bar|}}} | ! Bar}}
{{#if: {{{baz|}}} | ! Baz}}
|-
| {{{foo}}}
{{#if: {{{bar|}}} | {{!}} {{{bar}}}}}
{{#if: {{{baz|}}} | {{!}} {{{baz}}}}}
|}

Now, if I transclude that template and leave out {{{bar}}} and  
{{{baz}}}, I get this markup:

<table>
<tr>
<th> Foo
<p><br />
</p>
</th></tr>
<tr>
<td> {{{foo}}}
<p><br />
</p>
</td></tr></table>

This is clearly, then, caused by the newline between the canditional  
bar and conditional baz lines resolving to empty strings, making the  
foo cells in each row have paragraphs containing line breaks.  So how  
do I get rid of it without, say, putting both rows into one compact row?




More information about the MediaWiki-l mailing list