webroo / dummy-json

Generates random dummy JSON data in Node.js
MIT License
380 stars 61 forks source link

Add example with "each" to README #8

Closed mdrx-io closed 8 years ago

mdrx-io commented 8 years ago

Would it be possible to add an example that uses the "each" helper to the README? The README references the built-in, but its usage with dummy-json is not straightforward.

webroo commented 8 years ago

You'll need to pass through your own mock data in order to use the Handlebars "each" helper. I've added a small example to the readme that I hope will help: https://github.com/webroo/dummy-json#using-other-data

Here's another example using complex objects:

var myMockdata = {
  animals: [
    {species: 'fox'},
    {species: 'badger'},
    {species: 'crow'}
  ]
};
var template = '{{#each animals}}{{this.species}}{{/each}}';
var output = dummyjson.parse(template, {mockdata: myMockdata});