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

feat: correct implementation of partial block #699

Merged
merged 2 commits into from
Mar 15, 2025

Conversation

sunng87
Copy link
Owner

@sunng87 sunng87 commented Mar 15, 2025

Fixes #698 #696

This patch finally reimplements partial's block context correctly. The key is to remove all previous blocks and use a separated one for partial.

It corrects behavior of partial parameter, hash and merge_json:

  • if parameters is provided, either as path or literal, use it as base value; otherwise use this as base_value
  • if hash is provided, always merge it with base value:
    • if base value is associative type: object, array, string, merge them as map
    • if base value is non-associative type, return hash
      otherwise, use base value directly

When partial is rendered, reset blocks.

Tests added.

sunng87 added 2 commits March 15, 2025 00:02
@coveralls
Copy link

coveralls commented Mar 15, 2025

Coverage Status

coverage: 82.233% (+0.3%) from 81.928%
when pulling cf2a8d0 on fix/partial-context-merge
into e9c4fe7 on master.

@sunng87 sunng87 merged commit 7fb336a into master Mar 15, 2025
9 checks passed
@sunng87 sunng87 deleted the fix/partial-context-merge branch March 15, 2025 07:30
@hrydgard
Copy link

Thank you!

@sunng87
Copy link
Owner Author

sunng87 commented Mar 15, 2025

Just trying to validate on your project.

@sunng87
Copy link
Owner Author

sunng87 commented Mar 15, 2025

@hrydgard it should work now. I will look into another partial issue tomorrow and cut a release soon.

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.

6.3.1 generates incorrect output
3 participants