Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JADE: difference between for and each

Tags:

javascript

pug

Why is there a difference between

- for(var user in users) {
  p= user //output: user1
- };

and

each user in users
  p= user //output: [object Object]

according to http://jade-lang.com, they are aliasses, so why do they have a different output ?

List of users (JSON-format)

users = {
    "user1": {
        "firstname": "John",
        "lastname": "Doe"
    },
    "user2": {
        "firstname": "Jane",
        "lastname": "Roe"
    }
}
like image 388
Nike Sprite Avatar asked Dec 24 '15 21:12

Nike Sprite


1 Answers

Finally found a solution that works, I had to use value, index otherwise an object was returned

each value, index in users
  li= index //output: user1
like image 166
Nike Sprite Avatar answered Nov 20 '22 18:11

Nike Sprite