Quick iron.router question


#1

I’m using this

Router.route('/', function () {
    this.render('something');
});

Sure, it works as intended but how do i choose where the template “something” gets rendered?

Currently it puts the template in the bottom of the page, but i want it inside a div.
{{> something}} doesnt work since that displays the template all the time.
I hope you understand my question. I want to render different templates based on the route, inside the same div.

Just for hardcore clarification, im going to write it in an imaginary language :wink:

<div class="content">
    {{#if mysite.com/home}}
        {{> home}}
    {{/if}}
    {{#if mysite.com/help}}
        {{> help}}
    {{/if}}
</div>

#2

Iron Router’s docs explain this clearly

for your benefit, I’ll write a short example:

/* JS */

 // configure a layout (master) template
Router.configure({
layoutTemplate: 'layout'
});

// configure a specific route
Router.route('/',  {
    name: 'something'
});

/* HTML */
<template name="layout">
<div>
<!-- this is where your route would be rendered -->
{{> yield }}
</div>
</template>

// some template to render within layout
<template name="something">
<span>hi!</span>
</template>

#3

Thank you!

Can you link me to the docs where this is explained? I’ve rea the docs for 20 minutes, could not find it


#4

#5

Amazing, thank you :blush: