0
votes

I have a template:

<template name="outerTemplateName">
...
    {{> Template.dynamic template=inner}}
...
</template>

However, the template that i want to render as inner template also have a dynamic template inside it:

<template name="innerTemplateName">
...
    {{> Template.dynamic template=anotherInner}}
...
</template>

Is it possible to use BlazeLayout.render() to achieve something like the template below?

<template name="outerTemplateName">
...
    {{> innerTemplateName anotherInner="anotherInnerTemplateName"}}
...
</template>
1
Please post your rendering code. I have solved this already but let me first see, how you call BlazeLayout.render() at the moment. - Jankapunkt

1 Answers

0
votes

I don't know about passing Templates to other Templates but you can dynamically switch Templates by passing a String like this.

<template name="outerTemplate">
    {{> innerTemplate childTemplateName="templateA"}}
</template>

<template name="innerTemplate">
  {{#if showTemplate 'templateA' }}
    {{> templateA }}
  {{/if}}
  {{#if showTemplate 'templateB' }}
    {{> templateB }}
  {{/if}}
</template>

<template name="templateA">
    <h1>I am templateA</h1>
</template>

<template name="templateB">
  <h1>I am templateB</h1>
</template>

Template Helper

Template.innerTemplate.helpers({
    showTemplate : function (templateName) {
        return templateName === this.childTemplateName;
    }
});