Search code examples
meteoriron-router

Meteor - before Iron-Router


Before the advent of Iron-Router, what was the best way to switch between views/templates?

Right now, I can href a new location and iron-router will render the desired template, like so:

Router.route('/about', function(){
  this.render('about_template',{to:'stuff'});
  this.render('personnel_template',{to:'stuff'});
}, {where:'client'});

But how is this accomplished without routes? Do I just render the view when a certain action happens and just manually change the URL location?


Solution

  • First be sure you have the correct Layout template

    <template name="layout">
    {{> yield}}
    </template>
    

    and config like this.

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

    now try with this.

    Router.route('/about', {name: 'about_template'});
    

    and call like this on HTML.

    href="{{pathFor 'about_template'}}"