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

Refactor merge scope #157

Merged
merged 10 commits into from
Nov 28, 2023
Merged

Refactor merge scope #157

merged 10 commits into from
Nov 28, 2023

Conversation

guillemcordoba
Copy link
Collaborator

Depends on #155

Refactors the merge_scope helper into two separate ones. Here is the new documentation for them.

Without this, the use of merge_scope turns out to be quite constrained in some use cases, particularly when the template needs to merge two scopes at the same level. As an example:

export class A {
}
export class B {
}

With the old merge_scopes, it was impossible to add a new function to the end of both A and B, you had to choose between one of them. Now with the new helpers the templates can do it like this:

{{#merge previous_file_content}}
  {{#match_scope "export class A"}}
    {{previous_scope_content}}
    
    newFunctionA() {}
  {{/match_scope}}
  {{#match_scope "export class B"}}
    {{previous_scope_content}}
    
    newFunctionB() {}
  {{/match_scope}}
{{/merge}}

This has no impact on the built-in templates as they don't use this helper, but this custom template does. I'm the maintainer of that template and I need this change for it to work well.

@guillemcordoba guillemcordoba requested review from ThetaSinner and removed request for ThetaSinner November 25, 2023 18:33
@ThetaSinner ThetaSinner added the ShouldBackport/0.2 This change should be backported to develop-0.2 label Nov 28, 2023
@guillemcordoba guillemcordoba merged commit 94b3ef1 into develop Nov 28, 2023
1 check passed
@guillemcordoba guillemcordoba deleted the refactor-merge-scope branch November 28, 2023 12:27
ThetaSinner pushed a commit that referenced this pull request Nov 28, 2023
@ThetaSinner ThetaSinner removed the ShouldBackport/0.2 This change should be backported to develop-0.2 label Nov 28, 2023
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.

2 participants