Reputation: 4821
I'm having problems while rendering a jade template where I'd like to pass an array variable with objects that contains ObjectId (fmor Mongo)
{ name: 'fake',
slug: 'FAKE',
address: 'fake',
city: 'Madrid',
country: 'Spain',
_owner: 51f65388f98a405469000003,
_id: 51f65389f98a405469000007}
This is the representation when doing #{objects}.
This, obviously, leads to an TOKEN ILLEGAL... How can I insert this variables into jade without breaking anything.
Upvotes: 0
Views: 171
Reputation: 54514
It looks like it is due to the missing quotes, you should convert _owner and _id to strings before passing to the template.
{
name: 'fake',
slug: 'FAKE',
address: 'fake',
city: 'Madrid',
country: 'Spain',
_owner: '51f65388f98a405469000003', // convert to string
_id: '51f65389f98a405469000007' // convert to string
}
In mongoose, you can do
obj._owner.toHexString();
obj._id.toHexString();
Upvotes: 3