Search code examples
templatesmediawikiline-breaksmediawiki-templates

Unexpected Line Break in MediaWiki Template


So I have a MediaWiki template which I use within a table to represent one column. The code looks like this and works as I want it.

<includeonly>{{#if:{{{name|}}}|''{{{name}}}: ''|}}{{#if:{{{food|}}}|+{{Food|{{{food|}}}}}|}} {{#if:{{{condition|}}}|{{{condition|}}}|}}</includeonly>

When I use it with the input

{{Symbiosis|name=Groove|food=10|condition=if next to [[Apple Tree]], [[Dandelion]] or [[Straberry]]}}

I get the folling result which is as desired.

correct output

However now I want to extend this template and move the part with the food definition in another template because I need it elsewhere again. So I make a new ResourceList template which basically does the same as before.

<includeonly>{{#if:{{{food|}}}|+{{Food|{{{food|}}}}}|}}<includeonly>

and include it in my Symbiosis template to look like this.

<includeonly>{{#if:{{{name|}}}|''{{{name}}}: ''|}}{{ResourceList|food={{{food}}}}} {{#if:{{{condition|}}}|{{{condition|}}}|}}</includeonly>

But when I now use the same input as above I get a line break in my table to look like this. wrong output

Why is this? There are no spaces or linkebreaks in the template definitions. I don't really understand how MediaWiki handles all this, it is quite confusing and somewhat unintuitivive. All this whitespace and line break behavious is driving me nuts... Is there a way to tell MediaWiki that it might ignore all whitespaces and linebreaks within my template definition expect the ones I explecitly want to have?


Solution

  • I can't reproduce your error.

    I input all of the code from your second example exactly as written and it turned out like your first example. I tried it by itself and then I tried replicating your table based on the screenshot (see below), and in both cases no errant line break occurred.

    {| class="wikitable sortable"
    |- 
    ! width="33%" | Column A
    ! width="34%" | Column B
    ! width="33%" | Column C
    |- 
    | {{loremipsum}}
    | {{Symbiosis|name=Groove|food=10|condition=if next to [[Apple Tree]], [[Dandelion]] or [[Straberry]]}}
    | {{loremipsum}}
    |}
    

    Are you using a different css class in your table? Because sometimes that can cause unexpected wrapping or paragraph problems.