Let's handle !!merge << like other explicit YAML 1.1 tags, so that it works even if not separately enabled, and fix the options so that merge: true is a shorthand for customTags: ['merge'] (and combines with that option nicely, if they're both used).
This turned out to be a bit tricky to do "right", while also not introducing any breaking changes. In YAML 1.1, << is special, but only if it's used as a bare mapping key, and so I added an atKey flag into the ComposeContext and a default: 'key' value for tags, so that composition can take the node position into account.
The difficulty here is slightly compounded by a mistake we made early on (#22, CC @ikatyang) in mis-reading the !!mergespec and allowing multiple << keys to be present in a single mapping, which is not valid YAML -- but removing this support now would count as a breaking change, and that would be unfortunate.
While at this, I took the opportunity to add an optional addToJSMap(ctx, map, value) method that !!merge can use to customize how it's added to a JS map, so that its handling is now much less custom.
Fixes #579
Let's handle
!!merge <<
like other explicit YAML 1.1 tags, so that it works even if not separately enabled, and fix the options so thatmerge: true
is a shorthand forcustomTags: ['merge']
(and combines with that option nicely, if they're both used).This turned out to be a bit tricky to do "right", while also not introducing any breaking changes. In YAML 1.1,
<<
is special, but only if it's used as a bare mapping key, and so I added anatKey
flag into theComposeContext
and adefault: 'key'
value for tags, so that composition can take the node position into account.The difficulty here is slightly compounded by a mistake we made early on (#22, CC @ikatyang) in mis-reading the
!!merge
spec and allowing multiple<<
keys to be present in a single mapping, which is not valid YAML -- but removing this support now would count as a breaking change, and that would be unfortunate.While at this, I took the opportunity to add an optional
addToJSMap(ctx, map, value)
method that!!merge
can use to customize how it's added to a JS map, so that its handling is now much less custom.