如何将字符串连接到div类名?

时间:2014-12-23 20:09:02

标签: html handlebars.js templating

例如,<div class="hi_" + "1"> (这不起作用)

使用案例是我在手把中进行模板操作而我的代码是:

{{#each this}}
     <div class="box_" + {{id}}>
{{/each}}

我如何命名我的div?

1 个答案:

答案 0 :(得分:1)

您可以简单地将占位符插入到类属性中,如下所示:

{{#each this}}
    <div class="box_{{ id }}"></div>
{{/each}}