Template:Rawif

From Star Trek Timelines Wiki
Jump to navigation Jump to search


Usage


This is a special #if statement that preserves spaces and newlines in the 'then' and 'else'. Useful in conditional tables or any other situation where leading and trailing space and newline characters are important.

Example with rawif:

{| class=wikitable
! Rarity{{rawif|true|
{{!}} style{{=}}"color:DimGrey" {{!}} Basic}}{{rawif|true|
{{!}} style{{=}}"color:lightgray" {{!}} Common}}{{rawif|<!--false-->|
{{!}} style{{=}}"color:Green" {{!}} Rare}}
|}
Rarity Basic Common

Example with #if (note how loss of newlines creates a big mess):

{| class=wikitable
! Rarity{{#if:true|
{{!}} style{{=}}"color:DimGrey" {{!}} Basic}}{{#if:true|
{{!}} style{{=}}"color:lightgray" {{!}} common}}{{#if:<!--false-->|
{{!}} style{{=}}"color:Green" {{!}} Rare}}
|}
style="color:DimGrey" | Basic| style="color:lightgray" | common

Note that rawif does not have a # in front and has a | instead of :. Also, unlike #if, all = must be escaped using {{=}}.