Rhuan Caetano
Rhuan Caetano

Reputation: 295

Meteor Iron.Router dynamic template

I have a HomeLayout.html like this:

<template name="HomeLayout">
  <main>
     {{>Template.dynamic template=main}}
  </main>
</template>

And a LoginLayout.html like this:

<template name="LoginLayout">
  <main>
     <p> Login Layout Test </p>
  </main>
</template>

I'm trying to input this LoginLayout inside HomeLayout. To start the HomeLayout I use this code:

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

But i dont know how i can load this LoginLayout inside HomeLayout...

Upvotes: 0

Views: 415

Answers (1)

Michel Floyd
Michel Floyd

Reputation: 20226

Just define a helper that returns the template you want to dynamically insert:

Template.HomeLayout.helpers({
  main: function(){
    return "LoginLayout";
  }
});

Where you have {{>Template.dynamic template=main}} the above helper will evaluate main as a helper and that will return the layout you're looking for.

I don't know what your <main></main> tags are doing however.

Upvotes: 1

Related Questions