Answer the question
In order to leave comments, you need to log in
How to pull data from JSON to PUG using a loop?
I still don't fully understand how to use the loop in pug.
I have JSON:
"nav": [
{
"link": {
"title": "banana",
"href": "/banana"
}
},
{
"link": {
"title": "tomato",
"href": "/tomato"
}
},
{
"link": {
"title": "mango",
"href": "/mango"
}
}
]
ul
each entry in nav.link
li: a(href= entry.href)= entry.title
Answer the question
In order to leave comments, you need to log in
I still don't fully understand how to use the loop in pug.
-
const data = {
"nav": [
{
"link": {
"title": "banana",
"href": "/banana"
}
},
{
"link": {
"title": "tomato",
"href": "/tomato"
}
},
{
"link": {
"title": "mango",
"href": "/mango"
}
}
]
};
each item in data.nav
li: a(href=item.link.href) !{item.link.title}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question