Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active September 18, 2020 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mficzel/d2e9b41e0afc33be874af6b1686a144d to your computer and use it in GitHub Desktop.
Save mficzel/d2e9b41e0afc33be874af6b1686a144d to your computer and use it in GitHub Desktop.
Filter lists with Neos.Fusion:Reduce
foo = Neos.Fosion:Reduce {
items = ${something}
initialValue = ${[]}
# when the condition matches include the item into the result
# otherwise return sam array as before
itemReducer = ${ (__condition__) ? Array.push(carry, item) : carry}
#defaults
itemName = 'item'
carryName = 'carry'
}
bar = Neos.Fosion:Reduce {
items = ${something}
initialValue = ${[]}
# when the condition matches include the item into the result
# otherwise return sam array as before
itemReducer = Neos.Fusion:Case {
match (
condition = ${ __condition__ }
renderer = ${Array.push(carry, item)}
)
default {
condition = true
renderer = ${carry}
}
}
#defaults
itemName = 'item'
carryName = 'carry'
}
@lorenzulrich
Copy link

foo = Neos.Fosion:Reduce should be foo = Neos.Fusion:Reduce { (and same for bar)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment