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

Make Template.contentBlock consistent #358

Merged
merged 3 commits into from
Apr 6, 2022

Conversation

znewsham
Copy link
Contributor

@znewsham znewsham commented Dec 24, 2021

Currently, content rendered in {{> Template.contentBlock}} behaves differently depending on whether data is passed in:

<template name="goodTemplate">
  {{>Template.contentBlock}}
</template>

<template name="badTemplate">
  {{>Template.contentBlock someData}}
</template>

<template name="whatever">
{{#each thing in things}}
  {{#goodTemplate}}
    {{thing}} {{!-- thing will exist}}
  {{/goodTemplate}}

  {{#badTemplate}}
    {{thing}} {{!-- thing will not exist}}
  {{/badTemplate}}
{{/each}}
</template>
...

This PR fixes this situation by checking if the immediate parent is a with and the grandparent is a InOuterTemplateScope (in addition to if the parent is InOuterTemplateScope)

It also makes a readability change - that while statement was hard to parse.

Copy link
Collaborator

@StorytellerCZ StorytellerCZ left a comment

Choose a reason for hiding this comment

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

Nice, can you please update the chagelog as well?

@znewsham
Copy link
Contributor Author

@StorytellerCZ done - not sure when it will be released, so left it as 2022-XXX

@StorytellerCZ
Copy link
Collaborator

Alright, I'll see if I can spare more time to take a deeper look. If everything works great, then I would like to have this as a final piece for 2.6 release.

@StorytellerCZ StorytellerCZ mentioned this pull request Jan 1, 2022

// in the case of {{> Template.contentBlock data}} the contentBlock loses the lexical scope of it's parent, wheras {{> Template.contentBlock}} it does not
// this is because a #with sits between the include InOuterTemplateScope
if (currentView.parentView.name === "with" && currentView.parentView.parentView && currentView.parentView.parentView.__childDoesntStartNewLexicalScope) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would personally break the lines for better readability but that's optional, since we have no definite linter yet (I think)

@jankapunkt
Copy link
Collaborator

Is this to be included in 2.6?

@StorytellerCZ
Copy link
Collaborator

StorytellerCZ commented Mar 28, 2022

@jankapunkt if it is to be merged, then yes. Could go out as a patch, I think.

@fredmaiaarantes
Copy link
Member

@jankapunkt if it is to be merged, then yes. Could go out as a patch, I think.

If what's missing for version 2.6 is done soon, this can be merged into version 2.6.

@fredmaiaarantes fredmaiaarantes added this to the Blaze 2.6 milestone Apr 5, 2022
@StorytellerCZ StorytellerCZ changed the base branch from master to release-2.6 April 5, 2022 13:35
@StorytellerCZ StorytellerCZ merged commit 4a52314 into meteor:release-2.6 Apr 6, 2022
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.

4 participants