Closed Bestra closed 9 years ago
Would this work with components as well?
yes. I've got this test on my local branch.
test("block form works for components", function(){
var emblem = w(
"= my-component as item",
" p {{item.name}}"
);
compilesTo(emblem,
'{{#my-component as |item|}}<p>{{item.name}}</p>{{/my-component}}');
});
Could we keep the |
characters?
In general, my opinion is that mustache content should be a straight copy into htmlbars as much as possible. There are many places where that is not true today, but I consider those legacy.
When we build custom syntaxes, they make it more difficult for new users to understand what is happening. The syntaxes are less trivial to support, and need documentation.
I'd prefer to see:
=each collection as |item index|
p {{item.name}}
I'm a big fan of keeping the |
characters as well. This would also make it a bit more readable when you are passing in multiple parameters to a component.
That shouldn't be a problem at all, and I agree. I think part of my reluctance to use them at first was just the roundabout way that I got the parser expressions to work. Adding the |
characters will probably make the parser code simpler rather than more complex. I'll get on it shortly.
@Bestra you can make the start token as\w+|
like it is in Handlebars, instead of using a separate token for as
and |
.
For sure.
@Bestra I presume you plan to back out the changes to the AST and just put the full mustache expression in the AST name
?
@mixonic those were my thoughts this morning. Then I worked 9 hours and completely forgot. Glad you're way ahead of me :smile: .
I'm inclined to roll with this, though I do want that warm fuzzy of a +1 from @bantic.
Cool. I'll take a look this morning.
@bestra could you rename the blockParamNames plural rule to the singular? After that this is :+1: from me, thank you!
@bantic I was lucky that the mustache parser code was really easy to understand. I went from "I will probably never be able to do this" to "holy crap I can do this" in about a half hour. Now I can finally use the new (really useful) hotness in our templates!
Gracias @Bestra :-) Will cut a release soon.
Hi @mixonic - when do you think you'll cut a new release of this? I'm in upgrade limbo - and this is a blocker :heart:
becomes
For now I'm having the mustache parser output block params as
null
rather than an empty array, but that's easily changed. Comments welcome; this is the first time I've messed with a parser.