meteor: getting error "No Iron.Layout found so you can't use yield"

942 views Asked by At

just getting started with meteor following this autoform tutorial:

http://www.webtempest.com/meteor-js-autoform-tutorial

have these simple files: main.html:

<head>

  <title></title>
</head>
<body>
<div class="container">
    <h1>Posts</h1>

  {{> quickForm collection="Posts" id="insertPostForm" type="insert"}}
</div>

<template name="main">
    <div class="container">
      {{> yield}}
    </div>
</template>
</body>

post.html:

<template name="post">
    <h1>Edit Post</h1>
  {{> quickForm collection="Posts" id="updatePostForm" type="update" doc=this}}
    <a class="btn" href="/">Back</a>
</template>

posts.html:

<template name="posts">
    <h1>Add Post</h1>
  {{> quickForm collection="Posts" id="insertPostForm" type="insert"}}

    <ul>
      {{#each posts}}
          <li><a href="{{pathFor 'post.show'}}">{{title}}</a> - {{content}}</li>
      {{/each}}
    </ul>
</template>

and the router:

Router.configure({
    layoutTemplate: 'main'
});
Router.route('/', 'posts');
Router.route('/posts/:_id', function () {
    var item = Posts.findOne({_id: this.params._id});
    this.render('post', {data: item});
}, {
    name: 'post.show'
});

When I run this, I get this error:

Error: No Iron.Layout found so you can't use yield! iron_layout.js:410

What can I do to fix this, please?

1

There are 1 answers

0
Mark Leiber On BEST ANSWER

What you have in your main.html is invalid. The </body> tag should not be after your layout definition. Change it to:

<head>

  <title></title>
</head>
<body>
<div class="container">
    <h1>Posts</h1>

  {{> quickForm collection="Posts" id="insertPostForm" type="insert"}}
</div>
</body>

<template name="main">
    <div class="container">
      {{> yield}}
    </div>
</template>