[英]Passing JSON to Jade from Node
JSON passed to template engine, Jade: JSON传递给模板引擎Jade:
[ { _id: 531fb4f6ae8a7ad5a58c65fa,
goals: 'adsfasdfasdfas',
exam: 'asdfasdf',
__v: 0 },
{ _id: 531fb5cadd70a399a6ed1213,
goals: 'asdfasdfasdf',
exam: 'adsf',
__v: 0 } ]
The Jade template: Jade模板:
h1 Listings
for i in data
#{i.exam}
The output: 输出:
---empty space---
I can output #{i} just fine. 我可以输出#{i}很好。 I'm getting rather frustrated with Jade and wondering if I should go back to Django, which is super forgiving.
我对Jade感到非常沮丧,想知道是否应该回到Django,这是超级宽容的。 Anyone have any ideas why this isn't working?
任何人有任何想法为什么这不起作用?
Thanks! 谢谢!
Add a html tag to the Jade template: 将一个html标记添加到Jade模板中:
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. 并确保将String的值括在引号中。
If you need show datas without html tags, use |
如果需要不带html标记的显示数据,请使用
|
symbol; 符号;
example: 例:
h1 Listings
for i in data
| #{i.exam}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.