Javascript 车把-预期和#x27;开反链'';逆'';打开端块';,得到';EOF';
我正在试用车把,并使用以下简单模板:Javascript 车把-预期和#x27;开反链'';逆'';打开端块';,得到';EOF';,javascript,node.js,express,handlebars.js,Javascript,Node.js,Express,Handlebars.js,我正在试用车把,并使用以下简单模板: <html> <head></head> <body> <h1>{{title}}</h1> <p>{{body}}</p> {{#each list}} <ul> <li>{{@index}}. {{this}}</li> </ul> <
<html>
<head></head>
<body>
<h1>{{title}}</h1>
<p>{{body}}</p>
{{#each list}}
<ul>
<li>{{@index}}. {{this}}</li>
</ul>
</br>
{{{htmlTag}}}
{{#if user.admin}}
<button class="launch">Launch Spacecraft</button> {{else}}
<button class="login"> Log in</button>
{{/if}}
{{!-- This is a comment --}}
</body>
</html>
渲染页面时,出现以下错误:
错误:/home/ubuntu/workspace/src/views/index.hbs:Parse Error on line
20:
...}}
-------------------^
应为“OPEN\u INVERSE\u CHAIN”、“INVERSE”、“OPEN\u ENDBLOCK”,得到“EOF”
在Object.parseError(/home/ubuntu/workspace/node_modules/handlebar/dist/cjs/handlebar/compiler/parser.js:267:19)
在Object.parse(/home/ubuntu/workspace/node_modules/handlebar/dist/cjs/handlebar/compiler/parser.js:336:30)
在HandlebarsEnvironment.parse(/home/ubuntu/workspace/node_modules/handlebar/dist/cjs/handlebar/compiler/base.js:46:43)
在compileInput(/home/ubuntu/workspace/node_modules/handlebar/dist/cjs/handlebar/compiler/compiler.js:514:19)
在ret(/home/ubuntu/workspace/node_modules/handlebar/dist/cjs/handlebar/compiler/compiler.js:523:18)
at/home/ubuntu/workspace/node_modules/hbs/lib/hbs.js:63:19
在tryToString(fs.js:456:3)
在FSReqWrap.readFileAfterClose[完成时](fs.js:443:12)
任何关于我在模板中做错了什么的建议
谢谢你的回复 错误状态:
期望(…),得到EOF
其中:
{{/each}
:
{{#each list}}
<ul>
<li>{{@index}}. {{this}}</li>
</ul>
</br>
{{{htmlTag}}} {{#if user.admin}}
<button class="launch">Launch Spacecraft</button> {{else}}
<button class="login"> Log in</button> {{/if}} {{!-- This is a comment --}}
{{/each}} <!-- HERE -->
{{{#每个列表}
- {{@index}}。{{this}}
{{{htmlTag}}{{{#if user.admin}}
发射航天器{{else}
登录{{/if}{{!---这是一条注释--}
{{/每个}}
这通常是由于没有关闭{{each}
,{{if}
,或任何其他控制语句,但不能由未关闭的html标记(如
,
)或任何其他html标记造成的。这是因为没有关闭{each}
。
在循环的末尾添加{{/each}
{{#each list}}
<ul>
<li>{{@index}}. {{this}}</li>
</ul>
</br>
{{{htmlTag}}} {{#if user.admin}}
<button class="launch">Launch Spacecraft</button> {{else}}
<button class="login"> Log in</button> {{/if}} {{!-- This is a comment --}}
{{/each}} <!-- HERE -->