Operators
It is important to note that white space is removed from the beginning and the end of both operands before operation.- = or ==
- Equal.
- !=
- Not equal.
- ||
- Logical OR. If either operand is true, condition is true.
- &&
- Logical AND. If both operands are true, condition is true.
- >
- Greater than.
- <
- Lesser than.
- >=
- Greater than or equal to.
- <=
- Lesser than or equal to.
- contains
- True if the left operand contains the right operand.
- notcontains
- True if the left operand isn't found from the right operand.
- empty
- True if the left operand is empty. Right operand is not needed and ignored if used.
- notempty
- True if the left operand is not empty. Right operand is not needed and ignored if used.
- begins
- True if the left operand begins with the right operand.
- notbegins
- True if the left operand doesn't begin with the right operand.
- ends
- True if the left operand ends with the right operand.
- notends
- True if the left operand doesn't end with the right operand.
b:if tags
b:else<b:else>...</b:else>
|
Contents of <b:else> will be executed if a <b:if> before it is not. |
Attributes
Examples
Basic structure
<b:if condition="'foo' = 'bar'"> <p>Foo is bar.</p> </b:if> <b:else> <p>Foo is not bar.</p> </b:else> <!-- This will output: <p>Foo is not bar.</p> -->
To display data or not?
Here we will test if page has content inside <b:page.relatedinfo />.
If relatedinfo field is not empty we'll show topic and the content, but if not no topics will be shown.
<b:if condition="<b:page.relatedinfo /> notempty">
<h2>This might also interest you...</h2>
<b:page.relatedinfo />
</b:if>
Using AND and OR operators
You can have several conditions inside one <b:if> by using and and or operators.
<b:if condition="<b:value.foo/> = 5 and 'foobar' begins 'foo'"> This condition is true. </b:if>
More control (complexity) with parentheses
You can also force the precedence of operators by using parentheses.
<b:if condition="<b:value.foo/> = 5 and ('foobar' begins 'foo' or <b:page.metadata.url/> contains '/products/')">
This condition is true.
</b:if>

