Skip to content

Conditional rendering

If

The special :if attribute should be used to allow a block to render only under certain circumstances. Its value must be a valid php boolean expression.

In the following example, the entire <span> tag will not be rendered if $this->a > $this->b resolves to false

<span :if="$this->a > $this->b">
    a is greater than b!
</span>

Else

Use :else attribute to render a block following another whose :if expression has been resolved to false

<span :if="$this->a > $this->b">
    a is greater than b!
</span>
<span :else>
    a is smaller than b!
</span>

Else if

<span :if="$this->a > $this->b">
    a is greater than b !
</span>
<span :else-if="$this->a < $this->b">
    a is smaller than b !
</span>
<span :else>
    a is the same as b !
</span>