【问题标题】:How to nest Handlebars JS?如何嵌套 Handlebars JS?
【发布时间】:2012-09-27 02:36:28
【问题描述】:

由于我的 Handlebars JS 模板,我遇到了一个令人沮丧的错误。

Error: Parse error on line 9:
...      {{/each}}    {{/if}}
----------------------^
Expecting 'EOF'

有问题的车把:

{{if showSingle}}
    {{#with single}}
        {{> postSingle}}
    {{/with}}
{{else}}
   {{#each posts}}
        {{> postItem}}
    {{/each}}
{{/if}}

这样的嵌套是不可能的吗?

只是把事情放在上下文中,这工作正常:

{{#each posts}}
    {{> postItem}}
{{/each}}

【问题讨论】:

    标签: meteor handlebars.js


    【解决方案1】:

    缺少第一个if 中的#

    {{#if showSingle}}
        {{#with single}}
            {{> postSingle}}
        {{/with}}
    {{else}}
       {{#each posts}}
            {{> postItem}}
       {{/each}}
    {{/if}}
    

    【讨论】:

      猜你喜欢
      • 2019-06-13
      • 1970-01-01
      • 2018-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 2021-04-17
      • 1970-01-01
      相关资源
      最近更新 更多