我正在学习流星框架。我正在尝试渲染模板,但它会抛出此错误:
Errors prevented startup:
While processing files with static-html (for target web.browser):
client/html/sidebar.html:1: Expected <head> or <body> tag
我的layout.html文件是这样的:
<body>
{{> sidebar}}
</body>
和sidebar.html文件是这样的:
<template name="sidebar">
<h1>Hello</h1>
</template>
为什么它不能在layout.html上呈现?
答案 0 :(得分:0)
用名为&#34; layout&#34;的模板替换你的身体标签。 (例如)并在路由器配置中将此模板设为layoutTemplate。
<template name="layout">
{{> sidebar}}
{{> yield}}
</template>
以IronRouter为例:
Router.configure({
layoutTemplate: 'layout'
});
答案 1 :(得分:0)
您的问题是,您使用的是static-html
软件包,而不是blaze-html-templates
,这意味着所有模板代码都不会被处理
做:
meteor remove static-html
meteor add blaze-html-templates
在项目文件夹中查看是否有帮助