2012-10-05 30 views
1

由於我的Handlebars JS模板,我收到了令人沮喪的錯誤。如何嵌套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}} 

回答

2

從第一if缺少的#

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