Open paulyoung opened 10 years ago
Reproducable on http://ectjs.com:
The issue seems to stem the tracking of named blocks being somewhat naïve.
https://github.com/baryshev/ect/blob/0edfa8c4283153128363b53878e1bbdc4e6211c5/lib/ect.js#L303-L306
In my example, a block with the same name already exists (because I'm using the partial inside of a loop) and therefore the existing block is used.
This is problem of coffee-script itself, not ECT. You need to do something similar to this:
for i in [0..10]
do (i) ->
print i
And yes, blocks are not a good idea here.
This is problem of coffee-script itself, not ECT. You need to do something similar to this:
for i in [0..10] do (i) -> print i
I don't think that's correct. As you can see in the example above, the context is fine for unnamed blocks.
...
<span id="person_0">Hello Alice!</span>
...
<span id="person_1">Hello Bob!</span>
...
The issue appears to be that blocks can't be redefined as in #80.
If you can provide an example of how using do
fixes the issue, that would be great.
And yes, blocks are not a good idea here.
What do you mean by that?
Blocks are not good because #80 I'd use a function returning HTML
<% fn (attr) => %>
write something: <%= attr %>
<% end %>
...
<%- fn (attributes...) %>
Thanks for the tip. Seems to be the best option as a workaround for now.
Below is a contrived example that demonstrates my issue.
base
person
people
This produces: