Tania
Tania

Reputation: 1925

Meteor routing with iron router

I tried implementing iron:Router in the Meteor official TODO app tutorial. I wanted to make the default "/" route point to the "home" template so I modified my todoapp.html page and encapsulated the whole code in a template tag like this:

    <template name = "home">
    <head></head>
    <body>
    <ul>
          {{#each tasks}}
            {{> task}}
          {{/each}}
        </ul>
    </body>
    </template>
    <template name = "task">
<li>
 <span class="text"><a href="/user">{{username}}</a> - {{text}}</span>
  </li>
</template>

and in the todoapp.js I added this before isClient and isServer:

Router.route('/', {
    template: 'home'
});

Before adding the home template I got all the "task" objects. After encapsulating the code in a "home" template I don't get any of them. I followed the official tutorial to implement the "todo" app.

Can someone please help? Thanks in advance.

Upvotes: 1

Views: 43

Answers (1)

Christian Fritz
Christian Fritz

Reputation: 21384

head and body don't below in templates. Try this instead:

<head></head>
<body>
</body>

<template name="home">
  Home
  <ul>
    {{#each tasks}}
      {{> task}}
    {{/each}}
  </ul>
</template>

<template name="task">
  Task
</template>

Upvotes: 1

Related Questions