Reputation: 195
So I have a json file have where I have an array called technologies, I am trying to get a list of the array to be rendered in a pug file like this:
{
"projects": [
{
"id": "0",
"project_name": "A random quote generator",
"description": "This is a project that displays a random quote each time the button is clicked or every 5 seconds",
"technologies": ["HTML", "CSS", "JAVASCRIPT"],
}
This is how I am currently trying to use each in my pug file
ul
each val in `${projects[id].technologies}`
li= val
And this is how the data in currently being rendered, which I don't want
Can someone help?
Upvotes: 2
Views: 520
Reputation: 9738
Using template ${projects[id].technologies}
converts the array ["HTML", "CSS", "JAVASCRIPT"]
to a string, and when you loop throw a string you get letters and not array items
You should use something like this:
ul
each val in projects[id].technologies
li= val
Upvotes: 2