Template:Table section if

From Angelina Jordan Wiki

Documentation

This template is a conditional version of {{table section}}. It outputs code that forms a 2-column spanning header cell in a table if a certain condition is true (usually the presence of content to display, but any type of condition is possible). It can be used at the top of a table or in the middle of it.

It is not intended for general use in all tables. Its main purpose is to keep the template code relatively simple in infobox templates.

Note that this template outputs HTML-style table code (e.g., that would appear inside of a <table>…</table> element) rather than wiki-style (inside of {| … |}), since the former seems to be slightly more "robust" (i.e., less error-prone) than the latter. So it should only be used inside of HTML-style tables.

This template is used on a great many pages. Making any changes to it will cause lots of jobs to be added to the processing queue.

Usage

  • {{table section if|condition|heading}}
  • {{table section if|heading}}

In the second form, the heading is used as the condition. In other words, if there is a heading to show then show it; otherwise show nothing.

Examples

  • <table class="wikitable">{{table section if}}</table>
  • <table class="wikitable">{{table section if|Heading}}{{table row|1|2}}{{table row|3|4}}</table>
Heading
1 2
3 4
  • <table class="wikitable">{{table section if| |Heading}}{{table row|1|2}}{{table row|3|4}}</table>
1 2
3 4

This third example is kind of artificial, since the visibility of the header is usually tied to the visibility of the rows immediately below it. The following two examples are therefore more typical. They show how this template might be used inside of an infobox template and assume that {{{1|}}} and {{{2|}}} both evaluate to an empty string (false) while {{{3|}}} evaluates to "D" (a true value):

  • <table class="wikitable">{{table section if|{{{1|}}}{{{2|}}}|Heading}}{{table row if|{{{1|}}}|A}}{{table row if|{{{2|}}}|B}}</table>
  • <table class="wikitable">{{table section if|{{{2|}}}{{{3|}}}|Heading}}{{table row if|{{{2|}}}|B}}{{table row if|{{{3|}}}|C}}</table>
Heading
C D