Thinking about this a bit more, I don’t know how to know whether <%= ... %>
starts a block or not. Of course for a human it’s very simple to see: it ends with “do” or “{”, but if you have <%= {1, 2, 3} %>
it also ends with {
but it’s not a block. That means to implement this we have to parse the contents of <%= ... %>
to determine this, whereas before we didn’t care at all about this: it was just code that we pasted into the generated code.
I don’t know why it uses a different syntax, probably to avoid having to parse the Ruby code inside of it to determine if there’s a block.
Now I understand this
Yea, also if it ends with do |x|
it’s also harder to know. There’s no heuristic we can use, we must use a crystal parser that supports broken expressions (because foo do
isn’t valid crystal code).
So I think we can go with <%|= foo do |i| %>
like in erubi. It’s probably clearer to the reader what’s going on, I’m not sure.
In any case, I won’t do any of this right now, it’s just too complex for my limited time. Sorry!