Meteor 1.2 Pass @Index for a children's template

Just started using Meteor so that I could skip something basic. In Meteor 1.2, they have the {{@index}} directive.

In the template, if I have:

 ... {{#each items}} {{@index}} {{> childTemplate}} {{/each}} ... <template name="childTemplate"> {{@index}} </template> 

@index in the main template will work, but the one in the childTemplate will not. The work I did to use it was a call to childTemplate going through @index :

 {{> childTemplate @ index=@index }} 

Is this the right way to do this? Or is there something more meteoric?

+5
source share
1 answer

Yes that thin

There is a similar question that I answered here: -

How to get @index nested #each in meteor

But in this case, transferring it is in order.

Meteor has "../var" to go to the parent context, but this is a template context, not every block, so I don’t think there is a more expensive way

+4
source

Source: https://habr.com/ru/post/1240476/


All Articles