Help test the preview release with new upcoming Blaze features (#each-in, #let, @index)


Hey everyone,

Some of you might have seen this PR I opened a while ago. Good news: it passed a superficial stage of code review and now is ready for testing. Please, try out this preview release with the following features and let us know what you think.

#each in

The new syntax to #each that introduces a new variable to refer to the current object, in comparison to the old syntax, doesn’t change the current data context.

  {{#each person in people}}


#let allows you to introduce new variables-synonyms to other helpers or values in the data context.

  {{#let name=getFullName}}
     {{name}} is {{age}} years old.


The features above made the implementation of @index in #each a lot easier. You can use it like this:

  {{#each person in people}}
    <p>{{}} - {{@index}}</p>

How to test the preview release:

You can run Meteor with the --release EACH-IN@0.0.3. That’s it, you can create a new project by running meteor --release EACH-IN@0.0.3 create name-of-your-project or you can upgrade your existing project with meteor --release EACH-IN@0.0.3 update.

Let us know what you think of the new features!


Does it work with WINDOWS-PREVIEW@0.1.7?


It’s supposed to work, yes. You can run into dependencies conflict since windows versions were never released officially.


nice !
I will test it later
Is this in ‘devel’ ?
maybe we should have a category for pre ? or testingCore ? or something like that!


I really like this set of new features, so thank you for that :sunny: I will make sure they work as expected in meteor-jade before the final meteor release.


Good work @slava :+1:


It is not on devel.


This is great, so much needed. :smile:


Typo in your post:

  {{#each person in people}}
    <p>{{}} - {{@index}}</p>

should be:



thanks, fixed. The syntax highlighting is off and I didn’t notice that :frowning:

P.S. Discourse smileys are terribly picked


I found something, which might be an issue or not:

You can use:

		{{#each th_roles}}
  {{> role role=this}}

But this leads to an error (until you rename template ‘role’) :

			{{#each role in th_roles}}
  {{> role role=role}}


Just need a confirmation:

With the #each in syntax, you need to use #with to set the context if you want to access the state of the variable from within an event handler, right?

					{{#each author in authors}}
  {{#with author=author}}
    <button class="clickMe">Click Me</button>
	'click .clickMe': function(event, template) 		{


In this case it makes sense to me: template names and helpers and variables all share the same namespace. By writing {{> role role=role}} you refer to the closest definition of ‘role’, in this case, a variable defined in #each.


Right, this is not the prettiest thing though.


This is not pretty, but I prefer it over the old syntax anyway (find it more self-commented).


@slava Obviously spacebars is distinct from handlebars - but what was the reasoning behind diverging from the existing Handlebars Syntax- {{#each object as |value index|}} (See Handlebars Source)


Thanks for pointing this out! To be honest, I had no idea this is the official Handlebars syntax. I saw it in the Ember “future plans” docs, but not in Handlebars. I was referring to this page: Even current Ember implementation implements #each foo in foos, so this is at the very least, surprising.


@slava I’ve found handlebars is really poorly documented!

I just end up reading their unit tests to discover syntax.


After looking more into this and discussion this internally, here is what we found:

  • Handlebars syntax is not well documented. We consider features described in their documentation to be the “released” and perhaps “official” features.
  • Ember and Handlebars share the same Handlebars parser, although they have different syntax at this point.
  • Handlebars still uses the older syntax of each: #each things that changes the data-context
  • Ember introduced the newer syntax similar to what we propose in this thread: #each thing in things that doesn’t change the data-context.
  • Ember, the new unreleased version, is proposing the newest syntax of #each things |thing index|, which is not really loved by Ember community in their PR. It is not released yet.
  • There is no a word for Handlebars for changing their syntax, but their parser implements all of them as it is needed for Ember.

I like the fact that Spacebars is a familiar syntax to anyone who used Handlebars but the divergence is inevitable, and we can see how Ember and Ractive already diverge.


@slava So, what does that mean for #each in?

Also, it does appear in their official documentation (on the page you linked - search for #each users as |user userId| )