Meteor Iron Router layout template -
It looks like a basic one but I can not get the iron router to render my template in the right place on the page.
I have in my router controller:
router. Configure ({loadingTemplate: 'loading', notFoundTemplate: 'notFound'}); Router.map (function () (this.route ('home', {path: '/', template: 'home', layout template: 'layout'}); this.route ('post', {}); In the layout HTML page I have: > & Lt; body & gt; & lt ;! - Some other static page stuff here - & gt; & lt; div class = "container" & gt; & gt; template name = "layout" & gt; {{generated }}
The basic version of the Home Template looks like this:
& lt; template name = "home"> gt; h1 & gt; main page Th I have tried some variation on this but the home template is always closing body tags instead of the design container The first layout is presented at the bottom of the template
You have placed some tags incorrectly .
Templates should be empty of their own &; body tags:
& lt; Body & gt; & Lt ;! - There really is nothing here - & gt; & Lt; / Body & gt; & Lt; Template name = "layout" & gt; & Lt; Div class = "container" & gt; {{& Gt; Yield}} & lt; / Div & gt; & Lt; / Template & gt; This should work for your home route, but not your post because you have not given a layout template to them. / P> You can set a universal layout, so it will work on post and home (if you have not set any layout templates - which one Overrides the following): router. Configure ({loadingTemplate: 'loading', notFoundTemplate: 'notFound', layoutTemplate: 'layout'}); Therefore, the iron router is your layout placed in the body for you.
Comments
Post a Comment