0

Have been struggling with JSreport couple hours today making PDF report for my app. Now met the problem in if statement, where I need to compare index number to integer.

In Javascript I can compare like this if (partKey === 6), but with handlebars this is not working and I'll tried these with no luck:

{{#each computer.parts as |part partKey|}}
      <div class="item">
        <span>{{ part.productName }}, {{ part.weight }}g</span><br></br>
        {{ #if (eq partKey 6) }}
          <div style="page-break-before: always"></div>
        {{ /if }}
      </div>
      {{/each}}

I just want to change page after six objects. Also tried these; {{ #is partKey 6 }}, {{ #if_eq partKey 6 }}, {{ #equals partKey 6 }}.

Any ideas which should work?

If i print partKey like this {{ partKey }} it prints nicely. When I try to use it in if it gives a parse errpr, says partKey is Invalid.

  • Does this answer your question? [Handlebarsjs check if a string is equal to a value](https://stackoverflow.com/questions/34252817/handlebarsjs-check-if-a-string-is-equal-to-a-value) – 76484 May 10 '21 at 17:56
  • @76484 No. I tried that also. – Patriarkka May 11 '21 at 06:17

0 Answers0