Eri*_*ale 9 javascript templates template-engine pug
我想在循环中传递一个对象,如下所示;
数据结构:
things = [
{
title: 'foo'
, description: 'bar'
}
, {
title: 'baz'
, description: 'bam'
}
];
Run Code Online (Sandbox Code Playgroud)
index.jade:
- for thing in things
include things-template
Run Code Online (Sandbox Code Playgroud)
在上面的格式中,我希望能够将某种参数指定为包含的"locals".
事情-template.jade:
li
h3 #{title}
p #{description}
Run Code Online (Sandbox Code Playgroud)
这是可能的,还是我需要将它分配给另一个变量并在我的"thing-template"中引用它?
Arn*_*uin -3
由于您想包含现有模板,我猜您没有那么多。为什么不直接使用 \xc3\xa0 玉case块呢?
html\n body\n for thing in things\n case things-template\n when "simple"\n include simple\n when "complexe"\n include complexe\n default\n include simple\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1581 次 |
| 最近记录: |