Reputation: 10297
I'm following along with the tutorial here and, after adding the html and JavaScript to replace the default markup/code, I get, "Uncaught TypeError: Cannot read property 'helpers' of undefined"
Here is my HTML, straight from the tut:
<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>
...and here is my JavaScript, also straight from the tut:
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" }
]
});
}
All I see on the page is the h1 ("Todo List").
What is wrong, and how to rectify?
Upvotes: 0
Views: 1082
Reputation: 6676
Sorry, I answered without looking closely at your markup. Try the following:
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
{{> tasks}}
</div>
</body>
<template name="tasks">
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</template>
<template name="task">
<li>{{text}}</li>
</template>
Template.tasks.helpers
instead of Template.body.helpers
.
Upvotes: 1