1

In my .js file I have the following data structure

var menu = { "Sport":"Racing",
    "Region":{
        "AUS":{ "name":"APrk", "key":"1234" },
        "GB":{ "name":"Cran", "key":"5678" }
    }
};
res.render('layout.jade', {locals: {menu: menu}});

In my layout.jade I have the following

for item in menu
  p= item

This produces the following output

Racing

[object Object]

Which is on the right track. What I would like to know is how can I access the nested structures?

1 Answer 1

9

I believe you're looking for this

// layout.jade
each value, key in locals.menu
  // may nest more iteration
  each v, k in value

Iteration of object key/value does not grantee order. You may want to use array.

Details: https://github.com/visionmedia/jade#a9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.