canjs / can-stache

Live binding handlebars templates
https://canjs.com/doc/can-stache.html
MIT License
10 stars 13 forks source link

Misleading error message if {{#let ...}} is used without closing tag #675

Closed JaneOri closed 5 years ago

JaneOri commented 5 years ago

I was trying to pass variables between components without cluttering the vm:

{{#let bob=undefined}}
<my-component hasItem:to="bob" />

<div class="main-body">
  <other-component wantsItem:from="bob" />
</div>

I could not figure out what I was doing wrong partially because this was the error message: image This is the same error you'd get without using let if bob wasn't on the VM.

The actual problem is that the let I'm using is for defining it within its own block and has no close tag so the let var doesn't get added to the scope. That should maybe cause its own error?

It works fine if I remove the # or close the block, of course, but as someone new to the let expressions I didn't realize it until some time later what I did wrong. I just put bob on the VM and avoided let at the time.

Thank you for your time, 🍻

cherifGsoul commented 5 years ago

@James0x57 I can not reproduce the issue in this CodePen , can you please provide more information on how to reproduce the issue or correct my CodePen.

cherifGsoul commented 5 years ago

But the following case throws a warning:

{{#let bar="Bar"}}
  <child-com foo:from="bar"></child-com>

Unable to find key "bar".

The codepen for the warning https://codepen.io/cherifGsoul/pen/gyLGKX

cherifGsoul commented 5 years ago

{{# let }} ... doesn't run when the closing tag is missed

JaneOri commented 5 years ago

https://codepen.io/anon/pen/BEQmoG per convo in the bitovi community slack ^ Sorry I didn't see these responses sooner!