baryshev / ect

Fastest JavaScript template engine with embedded CoffeeScript syntax
http://ectjs.com
MIT License
626 stars 70 forks source link

Redefined blocks now actually work as expected #80

Open nfour opened 10 years ago

nfour commented 10 years ago

Fixes #79. I'm not 100% sure that this doesn't break anything but from my tests it seems to be fine. Would be great if someone who knows ECT could make this more elegant.

Basically makes this work as you would expect:

base.ect

<< block 'image' : >>
  <img src="111.png" />
<< end >>
<< include 'imageBox' >>
<< block 'image' : >>
  <img src="222.png" />
<< end >>
<< include 'imageBox' >>

imageBox.ect

<div class="imageBox">
  << content 'image' >>
</div>

The above example previously would compile both << include 'imageBox' >> to only the first block content ( `111.png ).

I'd imagine something like this could be used to make #50 work as well without too much pain.

paulyoung commented 10 years ago

This appears to fix #83 but without a test suite it's impossible to know the impact of these changes.

paulyoung commented 10 years ago

@baryshev could you take a look at this please?

nfour commented 10 years ago

Been using this in production for a few weeks now and I'm not seeing any problems, but, a test suite would be pretty nice.