ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

Looping through object arrays #279

Closed malikolabiyi closed 3 years ago

malikolabiyi commented 4 years ago

I have this list:

const list = [{"name":"Elon Musk","company":"Tesla"},{"name":"Bill Gate","company":"Microsoft"}]

I want to loop each of them and get their names and the company's value.

I have tried this, but it didn't work:

`{{#each list}} {{#each this}}

{{name}}

   <p>{{company}}</p>

{{/each}} {{/each}} `

UziTech commented 4 years ago

seems like a question for handlebars this project just adds handlebars to the express view engine.

You should try:

{{#each list}} <p>{{name}}</p> <p>{{company}}</p> {{/each}}