Search code examples
javascriptarrayshandlebars.jstemplate-engine

Access values using {{#each}} in a one dimensional array


I've found a lot of examples of using the {{#each}} helper to iterate over multi-dimensional arrays, but I can't figure out how to access each value in a one-dimensional array.

For example, take this array:

skills: ['Design', 'Development', 'HTML5', 'CSS', 'JavaScript'],

How do I output each item, in a helper like below?

template: Handlebars.compile(
'<div>' + 
    '{{#each skills}} {{ the_item_output }} {{/each}}' +
'</div>'
),

What do I need to put in placed of {{ the_item_output }} to see the actual item?


Solution

  • {{#each skills}}
      <li>{{this}}</li>
    {{/each}}