NAME
Catmandu::Fix::Bind::list - a binder that computes Fix-es for every element in a list
SYNOPSIS
# Create an array:
# demo:
# - test: 1
# - test: 2
add_field(demo.$append.test,1)
add_field(demo.$append.test,2)
# Add a foo field to every item in the demo list, by default all
# fixes will be in context of the iterated path
do list(path:demo)
add_field(foo,bar)
end
# Loop over the list but store the values in a temporary 'loop' variable
# Use this loop variable to copy the list to the root 'xyz' path
do list(path:demo,var:loop)
copy_field(loop.test,xyz.$append)
end
# This will result:
# demo:
# - test: 1
# - test: 2
# xyz:
# - 1
# - 2
DESCRIPTION
The list binder will iterate over all the elements in a list and fixes the values in context of that list.
CONFIGURATION
path
The path to a list in the data.
var
The loop variable to be iterated over. When used, a magic field will be available in the root of the record containing iterated data.