Menu icon Foundation
How do I use json data on Foundation 6 template system?

I saved a simple file called events.json inside data folder. The contents look like that:

{ "events":
[
{
"name": "Test1",
"date": "18/01/2016"
},

{
"name": "Test2",
"date": "18/02/2016"
}
]
}

However, when I tried calling this data inside my template, it only returns [object, Object]
This is how I'm calling it:

{{#each event}}

{{this}}

{{/each}}

I tried using {{this.name}}, but it returns nothing.

JSONpaniniFoundationdatatemplate

I saved a simple file called events.json inside data folder. The contents look like that:

{ "events":
[
{
"name": "Test1",
"date": "18/01/2016"
},

{
"name": "Test2",
"date": "18/02/2016"
}
]
}

However, when I tried calling this data inside my template, it only returns [object, Object]
This is how I'm calling it:

{{#each event}}

{{this}}

{{/each}}

I tried using {{this.name}}, but it returns nothing.

This post has been closed. No new replies can be added.

Hot Belgo almost 4 years ago

Drop the { "events": ... } wrapper - just use the array

Daniel Scarpim almost 4 years ago

OMG! It worked!
I knew it was something simple, but didn't imagine it was so simple. Thanks a lot!!