I feel like I may be doing to much for a simple problem.
If index = 0
, how do I increment index
in a template.
Ideally, I would like to do something like this.
{{index+1}}
From what I understand the solution is to write a helper function like the following.
import Ember from 'ember';
export function plusOne(params) {
return parseInt(params) + 1;
}
export default Ember.HTMLBars.makeBoundHelper(plusOne);
And then in the template you would do the following.
{{plus-one index}}
So hopefully, I am wrong and there is a much easier way to do this. And possibly a easier way to do 'simple' processing in the template. Not sure if there may be an objection because there may be 'to much' logic in the template.
Any guidance on this would be greatly appreciated.
Thanks!
And possible a easier way to do 'simple' processing in the template.
That would be a no. Handlebars templates were designed to be logicless. You should be doing any and all processing in your code. – Disproportionatestuff[]
and you want to display 1 next tostuff[0]
in your template, then 2 next tostuff[1]
, ect ... – Lysin{{index + 1}}
thing as well? Just want to make sure there is not a better way to do that. Thanks. – Lysin{{index + 1}}
as well. There's no way to do any processing or calculations directly in a template, you have to use a helper or computed property. – Disproportionate