Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The spirit of handlebars is that it is "logicless". Sometimes this makes us feel like we are fighting with it, and sometimes we end up with ugly nested if/else logic. You <em>could</em> write a helper; many people augment handlebars with a "better" conditional operator or <a href="https://github.com/wycats/handlebars.js/issues/616" rel="noreferrer">believe that it should be part of the core</a>. I think, though, that instead of this,</p> <pre class="lang-html prettyprint-override"><code>{{#if FriendStatus.IsFriend}} &lt;div class="ui-state-default ui-corner-all" title=".ui-icon-mail-closed"&gt;&lt;span class="ui-icon ui-icon-mail-closed"&gt;&lt;/span&gt;&lt;/div&gt; {{else}} {{#if FriendStatus.FriendRequested}} &lt;div class="ui-state-default ui-corner-all" title=".ui-icon-check"&gt;&lt;span class="ui-icon ui-icon-check"&gt;&lt;/span&gt;&lt;/div&gt; {{else}} &lt;div class="ui-state-default ui-corner-all" title=".ui-icon-plusthick"&gt;&lt;span class="ui-icon ui-icon-plusthick"&gt;&lt;/span&gt;&lt;/div&gt; {{/if}} {{/if}} </code></pre> <p>you might want to arrange things in your model so that you can have this,</p> <pre class="lang-html prettyprint-override"><code>{{#if is_friend }} &lt;div class="ui-state-default ui-corner-all" title=".ui-icon-mail-closed"&gt;&lt;span class="ui-icon ui-icon-mail-closed"&gt;&lt;/span&gt;&lt;/div&gt; {{/if}} {{#if is_not_friend_yet }} &lt;div class="ui-state-default ui-corner-all" title=".ui-icon-check"&gt;&lt;span class="ui-icon ui-icon-check"&gt;&lt;/span&gt;&lt;/div&gt; {{/if}} {{#if will_never_be_my_friend }} &lt;div class="ui-state-default ui-corner-all" title=".ui-icon-plusthick"&gt;&lt;span class="ui-icon ui-icon-plusthick"&gt;&lt;/span&gt;&lt;/div&gt; {{/if}} </code></pre> <p>Just make sure that only one of these flags is ever true. Chances are, if you are using this <code>if/elsif/else</code> in your view, you are probably using it somewhere else too, so these variables might not end up being superfluous.</p> <p>Keep it lean.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload