JSON passed to template engine, Jade:
[ { _id: 531fb4f6ae8a7ad5a58c65fa,
goals: 'adsfasdfasdfas',
exam: 'asdfasdf',
__v: 0 },
{ _id: 531fb5cadd70a399a6ed1213,
goals: 'asdfasdfasdf',
exam: 'adsf',
__v: 0 } ]
The Jade template:
h1 Listings
for i in data
#{i.exam}
The output:
---empty space---
I can output #{i} just fine. I'm getting rather frustrated with Jade and wondering if I should go back to Django, which is super forgiving. Anyone have any ideas why this isn't working?
Thanks!
Add a html tag to the Jade template:
h1 Listings
for i in data
p #{i.exam}
Maybe you didn't define 'data'. try this:
{
data:
[
{
_id: '531fb4f6ae8a7ad5a58c65fa',
goals: 'adsfasdfasdfas',
exam: 'asdfasdf',
__v: 0
}
]
}
and make sure the value of String enclosed in quotes.
If you need show datas without html tags, use |
symbol;
example:
h1 Listings
for i in data
| #{i.exam}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.