glimmerjs/glimmer.js

Passing parameters to named blocks causes Parse Error

shadyvd opened this issue · 2 comments

Attempting to pass a parameter to a named block in a {{yield to="named_block" "xyz"}} fashion causes the HBS Parser to throw an exception:
Expecting 'CLOSE_RAW_BLOCK', 'CLOSE', 'CLOSE_UNESCAPED', 'CLOSE_SEXPR', 'ID', 'OPEN_BLOCK_PARAMS', got 'STRING'

This is easily reproducible: Glimmer Playground Example

Stack:
Ember 3.26.1
Ember CLI 3.26.1
Glimmer/Component: 1.0.4

I believe this is an issue with the Jison parser. Positional arguments have to come first, before named arguments, so you should be able to do:

{{yield "xyz" to="named_block"}}

Unfortunately I don't think we can really give a better error message for this, because it occurs within Jison, which has very few if any abilities to hook into errors. We've been discussing rewriting that portion of the parser/compiler into something more modern which we would have more control over for that reason.

That worked for me. Thank you.

The Ember documentation definitely needs to be updated with this, though. Just a FYI.