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

Add support for merge keys #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

farcaller
Copy link

Adds support for merge keys and fixes #121.

(this is a copy of the closed #129)

@farcaller
Copy link
Author

@mosuem PTAL? The CLA bot says that I have the signature on file since #129 was created.

@mosuem
Copy link
Member

mosuem commented Mar 20, 2024

Could you add a changelog entry and some tests for this new feature?

@@ -174,6 +174,18 @@ class Loader {
children[key] = value;
event = _parser.parse();
}
if (children.containsKey('<<')) {
final mergeVal = children['<<']!;
if (mergeVal is! YamlMap) {
Copy link
Member

Choose a reason for hiding this comment

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

Supposedly the draft says:

---
- &CENTER { x: 1, y: 2 }
- &LEFT { x: 0, y: 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }

# All the following maps are equal:

- # Explicit keys
  x: 1
  y: 2
  r: 10
  label: center/big

- # Merge one map
  << : *CENTER
  r: 10
  label: center/big

- # Merge multiple maps
  << : [ *CENTER, *BIG ]
  label: center/big

- # Override
  << : [ *BIG, *LEFT, *SMALL ]
  x: 1
  label: center/big

Last two cases are not handled: https://yaml.org/type/merge.html

@jonasfj
Copy link
Member

jonasfj commented Jun 7, 2024

I propose that this feature should not be implemented in package:yaml, see #121 (comment)

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.

Add support for merge tags
3 participants