Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefined blocks now actually work as expected #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nfour
Copy link

@nfour nfour commented Jul 26, 2014

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
Copy link

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

@@ -302,7 +302,7 @@

TemplateContext.prototype.block = function (name) {
if (!this.blocks[name]) { this.blocks[name] = ''; }
return !this.blocks[name].length;
return true || !this.blocks[name].length;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter part of this conditional statement becomes unreachable with this change.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That to say, since this always returns true then it should likely not return anything and any code relying on it be refactored.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that so that the previous statement would still exist there and goad someone who knows why it's there to change it. It could merely be commented out though.

@paulyoung
Copy link

@baryshev could you take a look at this please?

@nfour
Copy link
Author

nfour commented Aug 21, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blocks cant be redefined!
2 participants