Passing an array of objects to a partial - handlebars.js
问题 Im trying to pass an array of objects into a partial as an argument: {{> partial [{title: "hello", year: "2015"}, {title: "hello2" year: "2015"}] }} and then on the partial: <div> {{#each this}} <label>{{title}}</label> <label>{{year}}</label> {{/each}} </div> ... but nothing shows up. Is there a way to pass array data to a partial? Thanks in advance. 回答1: Create a helper that parses the JSON and wrap your partial with this context. Template: {{#getJsonContext '[{"title": "hello", "year":