How do I Swap Template without Changing Route?


#1

Hello Meteorites,

Is there a way I can change the template that displays on a particular route without actually changing the route? let’s say I have a template that renders User Info and I want to replace it with another template that Edits the userinfo without changing the route from /dashboard to /edit-profile.


#2

well, tou can easily do something like this:

<template name="parent">
  {{#if variableResult }}
    {{> childTemplate1}}
  {{else}}
    {{> childTemplate2}}
  {{/if}}
</template>

#3

Thank you for your response. Pardon me if my questions are a bit odd but what could be variableResult be?


#4

result of template helper.
which for example returns result of Session.get('someVariable');


#5

Ahh okay! let me try it out.


#6

So I am trying to achieve a wizard like feel by changing the Form that displays on each step.

When the first form is completed, I want to set the next step as active and render a new form without changing the route.


#7

If you are on IronRouter simply

Router.current().render('<templateName>');

#8

Is there a better way to do this? If you have several different views (semantically, not Blaze.view objects or anything like that), then do you really have to put in a giant chain of {{#if}} blocks, each tied to a boolean helper?


#9

Template.dynamic