Someone is explaining to me {{> player}}

Working on examples of meteors and basically getting all over the place. I'm also new to steering games and just trying to wrap my head around. In the example of the leaders in the meteor. What's going on in this piece of code:

<div class="leaderboard">
   {{#each players}}
    {{> player}}
   {{/each}}
</div>

      

In particular, I am confused by {{> player}}. Why can't I just {{player}}? What is {{> player}} doing?

+3


source to share


2 answers


{{> player }}

calls partial with a name player

. As mentioned in this site

Particles come in handy when you have a piece of Handlebars.js template that needs to be used in multiple contexts.



While it {{player}}

is a placeholder for the value, you will go to the template to be displayed.

In jsfiddle, I created a sample code .

+5


source


The {{> player}} code calls the nested template. You can access the player values ​​generated # by iteration. It is helpful to keep your code organized.



+2


source







All Articles