[SOLVED] How to properly use dynamic templates?

It seems like you don’t understand Blaze and reactivity. Read docs http://docs.meteor.com/#/full/


Don’t do this in helper: if($('body').hasClass('page-index').

You need some reactive source which will track if it’s a home page or not. jQuery’s hasClass method is not reactive. You can use Session or ReactiveVar: http://docs.meteor.com/#/full/session, http://docs.meteor.com/#/full/reactivevar.


Blaze.render('bottomDrawer',Template.instance().find('.wrap'));

This is really wrong. Avoid manual DOM manipulation. Try not to use Blaze's methods in JavaScript at all.


Template.dynamic expects string, e.g. {{> Template.dynamic template='bottowDrawer'}}


This is how what you want can be achieved:

<template name="header">
    <header class="header">
        <div class="wrap">    
            {{> nav }}
            {{#if isHome}}
                {{> bottomDrawer}}
            {{/if}}
         </div>
    </header>
</template>
Template.header.helpers({
    isHome: function(){
        return Session.get('isHome');
    }
});

Session.set('isHome', true) should be called when you go to home page and Session.set('isHome', false) should be called when you leave home page.