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

[0.25] fix nested partials #732

Merged
merged 1 commit into from
Nov 1, 2017
Merged

[0.25] fix nested partials #732

merged 1 commit into from
Nov 1, 2017

Conversation

GavinJoyce
Copy link
Contributor

@GavinJoyce GavinJoyce commented Nov 1, 2017

fixes #728
addresses emberjs/ember.js#15791 (will be fixed once we release a new ember version with this change)

@GavinJoyce GavinJoyce changed the title [wip][0.25] fix nested partials [0.25] fix nested partials Nov 1, 2017
@GavinJoyce GavinJoyce changed the title [0.25] fix nested partials fix nested partials Nov 1, 2017
@GavinJoyce GavinJoyce changed the title fix nested partials [0.25] fix nested partials Nov 1, 2017
@GavinJoyce GavinJoyce changed the title [0.25] fix nested partials [wip] [0.25] fix nested partials Nov 1, 2017
value = evalScope[name];
} else {
value = locals[name];
}
Copy link
Contributor Author

@GavinJoyce GavinJoyce Nov 1, 2017

Choose a reason for hiding this comment

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

I'm unclear on the differences between locals and evalScope. Some questions:

  1. should locals contain the outerScope.getPartialMap() like I'm doing above or perhaps it belongs in evalScope?
  2. when iterating over the partialSymbols, should we just be checking evalScope or is it ok to fallback to locals too?

Copy link
Contributor

Choose a reason for hiding this comment

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

locals are supposed to win, they are names the partial introduced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks

@GavinJoyce GavinJoyce changed the title [wip] [0.25] fix nested partials [0.25] fix nested partials Nov 1, 2017
@GavinJoyce
Copy link
Contributor Author

CI seems flaky:

not ok 1 PhantomJS - error
    ---
        message: >
            Error: Browser exited unexpectedly
            Non-zero exit code: 127
            Stderr: 
             phantomjs: error while loading shared libraries: libicui18n.so.48: cannot open shared object file: No such file or directory
            
            
        Log: |
            { type: 'error', text: 'Error: Browser exited unexpectedly' }
            { type: 'error', text: 'Non-zero exit code: 127' }
            { type: 'error',
              text: 'phantomjs: error while loading shared libraries: libicui18n.so.48: cannot open shared object file: No such file or directory\n' }

Tests pass locally:

screen shot 2017-11-01 at 18 38 37

@GavinJoyce
Copy link
Contributor Author

This is ready for review

});

QUnit.test('nested partials within nested `{{#with}}` blocks', () => {
let template = compile(`{{#with 'Sophie' as |person1|}}Hi {{person1}} (aged {{age}}), {{person2}}, {{person3}} and {{person4}}. {{partial 'person2-partial'}}{{/with}}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I think I'll change this to

Hi {{person1}}. {{#with 'Sophie' as |person1|}}Hi {{person1}}...

so that we render something from the outer conext

Copy link
Member

Choose a reason for hiding this comment

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

👍 sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

outerEvalScope = {};
}

let mergedScope = Object.assign(outerEvalScope, locals);
Copy link
Member

Choose a reason for hiding this comment

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

We can't rely on Object.assign in this version, we have a shared assign utility method that we can use though.

export function assign(obj: any) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks

equalTokens(root, `Before [mantle Sophie (0) [outer Sophie (0) [inner Sophie (0)]]] After`);
rerender({ age: 0 }, { assertStable: true });
equalTokens(root, `Before [mantle Sophie (0) [outer Sophie (0) [inner Sophie (0)]]] After`);
});
Copy link
Contributor Author

@GavinJoyce GavinJoyce Nov 1, 2017

Choose a reason for hiding this comment

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

This test seems superfluous now that we have the nested partials within nested {{#with}} blocks test below, I'll remove it

Copy link
Member

Choose a reason for hiding this comment

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

Totally up to you, it certainly doesn't hurt to have two tests...

@rwjblue rwjblue merged commit 3cf41d3 into glimmerjs:release-0-25 Nov 1, 2017
@GavinJoyce GavinJoyce deleted the gj/fix-nested-partials branch November 1, 2017 19:09
@GavinJoyce
Copy link
Contributor Author

GavinJoyce commented Nov 1, 2017

I'll port these changes to master now in #730

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

Successfully merging this pull request may close these issues.

4 participants