-
-
Notifications
You must be signed in to change notification settings - Fork 21
Segment: Anchors
William W. Kimball, Jr., MBA, MSIS edited this page Mar 1, 2020
·
19 revisions
When your YAML data contains Anchors, you can select them by their unique name. For example:
anchored_hash: &anchor1
with: child
nodes: and values
another_anchored_hash: &anchor2
with: its
own: children
Select the entire anchored hash, anchored_hash
, via the name of its anchor: &anchor1
or /&anchor1
This segment type is especially useful for selecting named anchor values from the typical aliases:
array, commonly used in YAML files to define a lookup table of anchors. For example:
aliases:
- &anchorA Some value
- &anchorB Another value
- &anchorC True
- &anchorD 5280
You could select the value, Another value
, by using its array element index -- if you knew it -- or more simply by its known anchor name, like so: aliases[&anchorB]
or /aliases/&anchorB
.