Merge Key Language-Independent Type for
YAML Version 1.1
Working Draft 2005-01-18
Oren
Ben-Kiki
oren@ben-kiki.org
Clark
Evans
cce+yaml@clarkevans.com
Brian
Ingerson
ingy@ttul.org
2001-2005
Oren Ben-Kiki,
Clark Evans,
Brian Ingerson
This document may be freely copied provided it is not modified.
Status
This specification is a draft reflecting consensus reached by members of
the yaml-core
mailing list. Any questions regarding this draft should be
raised on this list.
URI:
tag:yaml.org,2002:merge
Shorthand:
!!merge
Kind:
Scalar.
Canonical:
N/A (single format).
Regexp:
<<
Definition:
Specify one or more mappings to be merged with the current one.
The <<
merge key is
used to indicate that all the keys of one or more specified maps
should be inserted into the current map. If the value associated
with the key is a single mapping node, each of its key/value pairs
is inserted into the current mapping, unless the key already exists
in it. If the value associated with the merge key is a sequence,
then this sequence is expected to contain mapping nodes and each
of these nodes is merged in turn according to its order in the
sequence. Keys in mapping nodes earlier in the sequence override
keys specified in later mapping nodes.
!!merge Examples
---
- &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