[Solved] Question: "{{scope.vm.prop}}" v.s. "{{this.prop}}" v.s. "{{prop}}"


#1

What is the difference between these three:

  • {{scope.vm.prop}}
  • {{this.prop}}
  • {{prop}}

Which is most explicit, and which do you think is most noob-friendly? Sometimes I’m afraid there might be some magic going on in CanJS because I don’t fully understand what it is doing behind the scenes, and I’d feel safer knowing I was explicitly referencing the view model or loop scope for instance.

If I wanted to be as explicit as possible, when would I use scope.vm, this, or just {{prop}} in for example the context of the root of a stache template, within an {{#if}}, and/or within an {{#each}}?

I know I can just use {{prop}} and CanJS will figure out what I mean for me, and the syntax will be more succinct, but I’d like to see what it looks and feels like to make everything explicit as possible.


#2

stache’s docs and the TodoMVC guide have recently been updated to show {{this.prop}} most places. This is the syntax you should use.

Use {{for(of)}} instead of {{each}}