0

So my problem is the following : I have an array of things, whose count is dynamic.

Now what I need, is in my template, to iterate 100 times, displaying a 100 rows ; and if things[i] exists, then display it on the row.

So I could do the basic iterator with mu is too short's answer. However in the {{#times}} loop I can't reference my things table by using the this index.

That is, if I write {{../things.[0]}}, it works (it displays the value) ; however with {{../things.[this]}}, it doesn't anymore.

Any idea how to do this ?

Thanks in advance,

Community
  • 1
  • 1
Eino Gourdin
  • 4,169
  • 3
  • 39
  • 67

1 Answers1

1

I don't understand, why don't you do:

{{#each things}}
  {{this}} //Here is your row
{{/each}}

Or do you need exactly to loop 100 times and display empty row if data does not exists? If so, then this may help(times helper was taken from your reference):

{{#times 100}}
  {{lookup ../things this}}
{{/times}}

If you have old version of handlebars without lookup helper, here is a source of it https://github.com/wycats/handlebars.js/blob/master/lib/handlebars/helpers/lookup.js

intale
  • 831
  • 5
  • 7