read arrays in jade

1

I need to read an array on my jade page.

In my controller I'm passing it as follows:

res.render('graphics/index', {namesClient:JSON.stringify(namesClient)}  

In jade I'm reading as follows:

var names= !{JSON.stringify(namesClient)};  

However, I need to load the information from namesClient[i].name , how do I read?

    
asked by anonymous 22.03.2016 / 14:57

2 answers

1

Do not convert string array between Node and Jade. Pass directly

res.render('graphics/index', {namesClient:namesClient}

and Jade node you can use namesClient[i].name . Only if you want to go to JavaScript (client side) do you need to convert to string.

    
22.03.2016 / 15:24
1
        - var names= JSON.parse(namesClient);
        - for (var i = 0; i < names.length; i++)
             label [j] #{names[i].name}
    
22.03.2016 / 18:40