Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested injected template in #each block does not render #63

Open
andreacremese opened this issue Jan 22, 2016 · 0 comments
Open

nested injected template in #each block does not render #63

andreacremese opened this issue Jan 22, 2016 · 0 comments

Comments

@andreacremese
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant