I am using Jade and
- if (userId !== null)
!= "<script type='text/javascript'>"
!= "userDetail.userId = "+userId.toString()+";"
- if (friends && friends.length > 0)
!= "userDetail.friends = "+friends+";"
!= "</script>"
In Javascript, userDetail.js,
var userDetail = {};
userDetail.userId = null;
userDetail.friends = [];
When I run this I get - Uncaught SyntaxError: Unexpected token ILLEGAL
I am able to refer to userDetail.userId in JS, but userDetail.friends appears as null. Any clue what's wrong ?
friends is an array of object {id, name, _id}