Jerome
Jerome

Reputation: 1192

How to display a template without displaying it inside the layout template?

Maybe my question is a bit unclear but I'm sure you'll understand with the pictures.

So in my Ironrouter configuration I have the following code:

Router.configure({
  layoutTemplate: 'layout',
  notFoundTemplate: '404',
  loadingTemplate: 'loading',
  fastRender: true,
});

the thing is when I want to display the 404 error it insert the 404 error template inside the layout template so it's a bit ugly: enter image description here

The layout is the menu left and the top bar + the footer. It's the template because everywhere I use this.

So how can I display only the template 404 without putting it inside the template layout ?

Upvotes: 0

Views: 29

Answers (1)

jordanwillis
jordanwillis

Reputation: 10705

There is no clean way to do this, however I have used this hack in the past. Use a route definition like this where 'errorLayout' refers to a template that is a special layout only for the 404 error.

Router.route('/(.*)', function() {
   this.layout('errorLayout');
   this.render('404');
   this.next();
});

The hack is originally from here.

Upvotes: 1

Related Questions