b:if

<b:if>...</b:if>

Displays and executes contents of <b:if> if given condition is true. If not, contents of <b:else> (if present) will be displayed.

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

condition

Defines a condition or conditions which must be true to output the contents inside <b:if>.

Format of the condition: [left operand] [operator] [right operand].

Operand can be a string inside single quotes ('), a single Bildy tag or numeric.

If you need to use single quotes inside a string, you have to escape it with \.

If you need to use the double quote character inside your operation (for example in attributes of a tag), please note that they need to be escaped with \. For each inner tag inside inner tag you must add one additional \ for their double quotes. See examples.

You can combine several conditions by using logical operators and and or with and operator taking precedence over or.

You can use parentheses to force the precedence.

Please note that logical operators (just like comparison operators) are case sensitive.

nocache

(optional)

If this attribute is defined, this block will not be cached.

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>