Abdul
Abdul

Reputation: 561

Using result of one helper function in another helper function within Handlebars

I am checking if there is anyway that I can use the result of one helper function in another helper function and how can I use it, for example, I am looping through as below

{{#each v.NOVNumber as |vv iindex|}}

And then if I am getting another element as below, using the same index:

{{get v.NOVNoticeTypeName iindex}}

Can I use this element that we have got in a statement like below, to check if that is first or last element etc?

{{#if (isFirst v.NOVNumber vv)}}

Upvotes: 1

Views: 99

Answers (1)

jrjohnson
jrjohnson

Reputation: 2459

You you can use helpers together to create more powerful functions. Ember Composable Helpers provides both a good pattern for using helpers together as well as the specific has-next and has-previous helpers that you need to know if an element is first of last.

An example using has-next

{{#if (has-next page pages)}}
  <button>Next</button>
{{/if}}

Upvotes: 3

Related Questions