无法读取undefined的属性'helpers'

Pue*_*gel 4 javascript meteor

Meteor出了测试版,我很兴奋使用它.我将它安装在我的Windows机器上(来自http://win.meteor.com/)并创建了一个应用程序.这是代码:

HTML:

<!-- simple-todos.html -->
<head>
  <title>Todo List</title>
</head>

<body>
  <div class="container">
    <header>
      <h1>Todo List</h1>
    </header>

    <ul>
      {{#each tasks}}
        {{> task}}
      {{/each}}
    </ul>
  </div>
</body>

<template name="task">
  <li>{{text}}</li>
</template>
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

// simple-todos.js
if (Meteor.isClient) {
  // This code only runs on the client
  Template.body.helpers({
    tasks: [
      { text: "This is task 1" },
      { text: "This is task 2" },
      { text: "This is task 3" }
    ]
  });
}
Run Code Online (Sandbox Code Playgroud)

它与官方流星教程中的代码完全相同.如果我运行该示例,标题将被渲染得很好.另一方面,该列表根本没有出现.不知何故,助手不起作用.我收到以下javascript错误:

未捕获的TypeError:无法读取未定义的属性'helpers'

在流星控制台中,没有打印错误或警告.我对流星感到非常兴奋,我希望将来能够将它用于制作应用程序,所以请帮我解决这个问题(可能非常简单).我希望它不仅仅是Windows中的问题(流星尚未正式发布用于Windows).

Aks*_*hat 5

模板需要定义<template name="xxx">.

<body>元素上没有帮助器.

不过,您可以使用全局帮助程序:

Template.registerHelper("tasks", function() {
    return [....]
});
Run Code Online (Sandbox Code Playgroud)

另一种方法是使用<template name="body">:

<body>
    {{>body}}
</body>

<template name="body">
  <div class="container">
    <header>
      <h1>Todo List</h1>
    </header>

    <ul>
      {{#each tasks}}
        {{> task}}
      {{/each}}
    </ul>
  </div>
</template>
Run Code Online (Sandbox Code Playgroud)