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


#1

My Meteor application seems to be working fine but I’m wondering why the browser console keeps reporting this error:

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

lib/router.js

Router.configure({
    layoutTemplate: 'application_layout'
});

Router.onBeforeAction(function () {
	if (!Meteor.userId()) {
		// If the user is not logged in, render the login template.
		this.render('login', {to: 'login'});
	} else {
		this.next();
	}
});

client/application_layout.html

<template name="application_layout">
	{{#if currentUser}}
		<div class="col-xs-2">left column</div>
		<div class="col-xs-8">{{> yield}}</div>
		<div class="col-xs-2">right column</div>
	{{else}}
		{{> yield "login"}}
	{{/if}}
</template>

#2

Hhmm, looks like I had a file named body.html like this:

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

Apparently, templates are not to be included in the body tag. Commenting it out resolved the error:

<body>
	<!-- {{> application_layout}} -->
</body>

Love me some spaghetti code, mmmm