meteor-jade icon indicating copy to clipboard operation
meteor-jade copied to clipboard

Nothing works inside each if no content provided after

Open Dartv opened this issue 9 years ago • 2 comments

Dunno if it's bug or not. Consider this code:

each items
  +Template.dynamic(template=../template data=this)

It just doesn't work, but if I add some content after all works fine.

each items
  +Template.dynamic(template=../template data=this)
// now it works

Dartv avatar Oct 14 '15 02:10 Dartv

---Confirmed this bug as happening also when using UI.ContentBlock to define your own components (that thing that's supposed to make #1 missing not hurt so much...)

I'll note that this happens with things that extend spacebars too, such as {{#sortable}}---

AlbinoGeek avatar Oct 23 '15 02:10 AlbinoGeek

Ignore my above comment.

This isn't really a bug per se, @RevelsGit explained an intentional situation. "this" is always the current data context, as {{this}} will literally output the value stored in "this.data (from the Template point of view.)" I would imagine this is because variables are compiled by Spacebars/Handlebars at the end of the day. Your point data=this would require a data context on the template being used in. The point of ../template means that the parent data context must also be set (as with ..)

If any of this is incorrect please feel free to correct, it's speculation as to how I see it working.

AlbinoGeek avatar Oct 26 '15 05:10 AlbinoGeek