[Mediawiki-l] Unexpected <p> and <br /> from a template

DanTMan dan_the_man at telus.net
Thu Aug 30 20:58:25 UTC 2007


I expect the extra empty paragraph has something to do with the extra 
newlines created by missing parameters, I use a little trick to only add 
newlines when needed, use something like this:

{|
|-
|Day
|Event{{#if:{{{1|}}}|<nowiki/>
{{!}}-
{{!}}1
{{!}}{{{1}}}
}}{{#if:{{{2|}}}|<nowiki/>
{{!}}-
{{!}}2
{{!}}{{{2}}}
}}{{#if:{{{3|}}}|<nowiki/>
{{!}}-
{{!}}3
{{!}}{{{3}}}
}}{{#if:{{{4|}}}|<nowiki/>
{{!}}-
{{!}}4
{{!}}{{{4}}}}}
|}

In simple terms, the <nowiki/> causes the newline after it to not be 
stripped out. That way the newline only shows up when the parameter is 
used, and you don't get extra newlines which would create those extra 
paragraphs.

~Daniel Friesen(Dantman) of The Gaiapedia, Wikia Graphical Entertainment Project, and Wiki-Tools.com

Emanuele D'Arrigo wrote:
> Hi everybody!
>
> Given the following template use:
>
> {{MonthListing
> |month=July
> |2=Manu.d birthday (1974)
> |9=Goofy.g birthday (1932)
> |15=Mickey.m birthday (1928)
> |17=Siggraph start
> |24=Siggraph ends
> }}
>
> and given the following template code:
>
> {|
> |-
> |Day
> |Event
> {{#if:{{{1|}}}|{{!}}-
> {{!}}1
> {{!}}{{{1}}}}}
> {{#if:{{{2|}}}|{{!}}-
> {{!}}2
> {{!}}{{{2}}}}}
> {{#if:{{{3|}}}|{{!}}-
> {{!}}3
> {{!}}{{{3}}}}}
> {{#if:{{{4|}}}|{{!}}-
> {{!}}4
> {{!}}{{{4}}}}}
> |}
>
> I obtain the following HTML:
>
> <table>
>
> <tr>
> <td>Day
> </td><td>Event
>
> </td></tr>
> <tr>
> <td>2
> </td><td>Manu.d birthday (1974)
> <p><br />
> </p>
> </td></tr></table>
>
> which all looks nice and dandy except for that
>
> <p><br />
> </p>
>
> I have no idea where those tags come from.
> I mean, they come from:
>
> {{#if:{{{4|}}}|{{!}}-
> {{!}}4
> {{!}}{{{4}}}}}
>
> because they are not there if I remove that snippet.
> But why 1 and 3 don't do the same?
>
> Is it because I'm using numerical parameter names
> and there's an ambiguity between parameter "4" and
> the fourth parameter? Are there workarounds?
>
> Manu
>
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at lists.wikimedia.org
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
>   



More information about the MediaWiki-l mailing list