Template:Table row if/doc

From Angelina Jordan Wiki
Revision as of 06:48, 13 January 2021 by Dcljr (talk | contribs) (doc created)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This is a subpage documenting Template:Table row if. To change the template, edit that page; to change the template's documentation (seen below), edit this one.

Documentation

This template either outputs the code for a table row or doesn't, based on a specified condition. If the condition evaluates to the boolean value "true", the output is a 2-column row, with a header cell ("label") in the left column and a data cell ("content") in the right column, as seen in the example below. (Note that the template outputs HTML-style table code, not wiki-style. This is because the former tends to be a little more "robust" [i.e., less error-prone] than the latter.)

The template is not intended to be used for general-purpose, arbitrary table rows. Its main purpose is to facilitate the creation of infobox templates.

Usage

  • {{table row if|condition|label|content}}
  • {{table row if|content|label}}

In the first form, if condition evaluates to a "true" boolean value (i.e., if it contains any non-whitespace characters), then output the table row using the given label and content, otherwise don't.

The second form is really just a shortcut where condition and content would be exactly the same — i.e., if there is any content to show, then show it in a table row, otherwise don't.

With any luck, the following example will clarify all of this.

Example

<table class="wikitable">
{{table row if|something is true|show|this content}}
{{table row if||do|nothing}}
{{table row if|content to show|show it with this label}}
{{table row if||nope}}
{{table row if| |neither}}
</table>

show this content
show it with this label content to show

As illustrated by the last template call in this example (the one with "neither"), if the first unnamed/positional parameter consists only of whitespace (in this case, a space character, but it could also be a newline or a combination of spaces and newlines), then it evaluates to "false" and the table row is not displayed.