<if>

DRYML’s ‘if’ test

Usage

<if test="&current_user.administrator?">Logged in as administrator</if>
<else>Logged in as normal user</else>

IMPORTANT NOTE: <if> tests for non-blank vs. blank (as defined by ActiveSupport), not true vs. false.

If you do not give the test attribute, uses the current context instead. This allows a nice trick like this:

<if:comments>...</if>

This has the double effect of changing the context to the this.comments, and only evaluating the body if there are comments (because an empty collection is considered blank)

Show Source


Edit this page