Search code examples
mediawikiwiki

Hide {{{X}}} if X parameter is empty in templates?


Let's say that I have this code:

{{Equipment|1=Test1|3=Test3}}

And this template:

====Head====
: {{{1}}}
: {{{2}}}
====Shoulders====
: {{{3}}}
: {{{4}}}
====Chest====
: {{{5}}}
: {{{6}}}
====Hands====
: {{{7}}}
: {{{8}}}
====Legs====
: {{{9}}}
: {{{10}}}
====Feet====
: {{{11}}}
: {{{12}}}

This returns:

Head[edit]
Test1
{{{2}}}
Shoulders[edit]
Test3
{{{4}}}
Chest[edit]
{{{5}}}
{{{6}}}
Hands[edit]
{{{7}}}
{{{8}}}
Legs[edit]
{{{9}}}
{{{10}}}
Feet[edit]
{{{11}}}
{{{12}}}

Is it possible to hide the empty {{{X}}} parameters, for example, could I hide {{{2}}}, {{{4}}}, {{{5}}} etc. since they are empty and the page will just display {{{X}}}.


Solution

  • You have to put a pipe after the parameters in the template code, like {{{2|}}} so that they won't show up if no value is given for them.