Including template without getting a duplicate warning


#1

I have a number of files that look like this.

<template name="home">
  {{#each story in stories}}
    <div class="row">
      <div class="col s12 m12">
        <div class="card">
          <div class="card-image waves-effect waves-block waves-light">
            <img class="activator img-responsive" src="/images/story/{{story.image}}">
          </div>
          <div class="card-content" style="background-color: #FFF; opacity: .5;">
            <span class="card-title activator grey-text text-darken-4 upper"><h2>{{story.title}}<i class="material-icons medium right">more_vert</i></h2></span>
            <p><a href="/story/{{story._id._str}}">Read</a></p>
          </div>
          <div class="card-reveal">
            <span class="card-title grey-text text-darken-4 upper"><h2>{{story.title}}<i class="material-icons medium right">close</i></h2></span>
            <p class="flow-text"><img style="width: 50% !important; padding-right: 10px;" src="/images/story/{{story.image}}" align="left"> {{story.description}}</p>
            <p><a href="/story/{{story._id._str}}">Read</a></p>
          </div>
        </div>
      </div>
    </div>
  {{/each}}
</template>

Below the name=“home” I’m looping through different stories / stories from helpers that have different find criteria. Because are 3 - 4 of these helper methods, I feel like I should be able to include a single template named story, correct? However I get an error when I do that.

I’d like to include the template like:

{{> story story=story}}

But I’m getting an error like such.

There are multiple templates named ‘story’. Each template needs a unique name

Quite obviously, I don’t understand the templating methodology of Meteor, so I’m doing this wrong. So I guess the question is, between the #each loop how to DRY that section of code for the other 4 helpers.

TIA.


#2

I was able to reproduce this, and it seems as if the iterator variable can’t be the name of the template.

The following fails

{{#each thumbnail in images}}
  {{>thumbnail thumbnail=thumbnail}}
{{/each}}

the following two work

{{#each thumbnail in images}}
  {{>thumbnailTemplate thumbnail=thumbnail}}
{{/each}}

or

{{#each image in images}}
  {{>thumbnail thumbnail=image}}
{{/each}}