In this post
Iterate over a base for loop to use Handlebars.js
An example of the 'repeat' helper is issued.
assistant
Handlebars.registerHelper('times', function(n, block) { var accum = ''; for(var i = 0; i < n; ++i) accum += block.fn(i); return accum; });
template
{{#times 10}} <span>{{this}}</span> {{/times}}
I can't seem to write this "CLI" way ... can someone enlighten me?
First of all, it will be your own helper file in /helpers , and it must have a dash for the recognizer to recognize it. - therefore I would not register it explicitly.
The default helper looks like this: helpers/repeat-times.js (the template should be the same ...)
import Ember from 'ember'; export function repeatTimes(input) { return input; } export default Ember.Handlebars.makeBoundHelper(repeatTimes);
so thereβs no need to register, no need to set a name ... I just canβt find clear documents on the syntax.: / (I took 20 or so hits) ...
Or should I make up a component instead? as suggested here: Block helper with ember-cli
sheriffderek Mar 04 '15 at 21:30 2015-03-04 21:30
source share