samedi 24 octobre 2015

How to check the value from json and compare in handelebar?

I want display different html for condition checking. It doesn't compare those two values and it always shows the first condition. How can I compare the predefined values to the original value from json so that it can execute properly.

<!--handlebar code-->
{{#each this}}
  {{#each visits}}
    <div class="row">
      {{#if variable_from_json }}
        <div class="col-lg-2 col-md-2 col-sm-2">
          <i class="fa fa-home"></i>
         </div>
        {else}}
         <div class="col-lg-2 col-md-2 col-sm-2">
          <i class="fa fa-plus symbol-hospital"></i>
         </div>
        {{/if}}
       </div>
     {{/each}}
   {{/each}}

   <!-- js code -->
       Handlebars.registerHelper('if', function(variable_from_json, options) {
         if(variable_from_json === "M") {
            return options.fn(this);
         } else {
             return options.inverse(this);
         }
        });

Aucun commentaire:

Enregistrer un commentaire