Answer the question
In order to leave comments, you need to log in
How to output data from json file array to pug loop?
I have an array with data in json format
{
"socialsData":
[
{
"title" : "Вконтакте",
"prefix" : "vk",
"href" : "https://vk.com/"
},
{
"title" : "Фейсбук",
"prefix" : "fb",
"href" : "https://fb.com/"
}
]
}
.pipe(pug({
locals : {
socials: JSON.parse(fs.readFileSync('src/modules/socials/socials.json', 'utf8')),
}
}))
ul.socials
each href, title, prefix in socials.socialsData
li.socials__item
a(href= '' +href target="_blank" class= 'socials__link socials__link--' +prefix)= title
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question