You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to inject a nested template with FlowRouter.render().
It all works until I try to inject the template inside an #each loop. In order to make it work I have to instead provide a getter function in the Template for the name of what is injected. (Looking at previous posts I think #12 ended up with a similar work around).
<!-- html file -->
<head>
</head>
<body>
</body>
<template name="layout">
<div>This is the main container</div>
<!-- This works -->
<h2>Trying to inject a nested template </h2>
{{> Template.dynamic template=mainPane}}
<!-- this woudl be similar to #12, and the template is injected with no problems -->
<h2>Trying to inject a nested template, in an if block</h2>
{{#if isTrue}}
{{> Template.dynamic template=mainPane}}
{{/if}}
<!-- This does not work-->
<h2>Trying to inject a nested template, in a loop block</h2>
{{#each getNumbers}}
{{> Template.dynamic template=mainPane}}
{{/each}}
<!-- This has a getter function for the name of the template to inject, and it works -->
<h2>Trying to inject a nested template, in a loop block with getter for the template's name</h2>
{{#each getNumbers}}
{{> Template.dynamic template= getInjectedTemplateName}}
{{/each}}
</template>
<template name="static">
<div>This is the injected content</div>
</template>
// JS file
if (Meteor.isClient) {
Template.layout.helpers({
getNumbers : function () {
var result = [];
for (var i = 0; i < 3; i++) {
result.push({i});
};
return result;
},
isTrue : function () {
return true;
},
getInjectedTemplateName : function () {
return "static";
}
})
}
FlowRouter.route("/", {
name: 'home',
action : function() {
BlazeLayout.render('layout', { mainPane : "static"});
}
});
Any help for make the FlowRouter.render() solution working without having to provide the getter?
The text was updated successfully, but these errors were encountered:
I am trying to inject a nested template with FlowRouter.render().
It all works until I try to inject the template inside an #each loop. In order to make it work I have to instead provide a getter function in the Template for the name of what is injected. (Looking at previous posts I think #12 ended up with a similar work around).
Any help for make the FlowRouter.render() solution working without having to provide the getter?
The text was updated successfully, but these errors were encountered: