【发布时间】:2012-05-01 14:52:20
【问题描述】:
我想在循环中传递一个对象,如下所示;
数据结构:
things = [
{
title: 'foo'
, description: 'bar'
}
, {
title: 'baz'
, description: 'bam'
}
];
index.jade:
- for thing in things
include things-template
在上述格式中,我希望能够将某种参数指定为该包含的“本地”。
things-template.jade:
li
h3 #{title}
p #{description}
这可能吗,还是我需要将它分配给另一个变量并在我的“事物模板”中引用它?
【问题讨论】:
-
我强烈建议您采用 JSLint 规定的语法...
-
具体是什么,+Ates Goral?
-
我只是说大括号和逗号的放置不是很传统。如果您曾经想过采用不同的风格,我建议您坚持 Crockford(或 JSLint)规定的风格。您会经常在 OSS 项目中看到这种风格。它也非常类似于 Sun Java 风格。使用传统风格有助于与其他人合作......
-
@Martindale,我也很想要这个功能,但我不相信它会出现...... :(
标签: javascript templates template-engine pug