Last active
September 18, 2020 12:27
-
-
Save mficzel/d2e9b41e0afc33be874af6b1686a144d to your computer and use it in GitHub Desktop.
Filter lists with Neos.Fusion:Reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
foo = Neos.Fosion:Reduce
should befoo = Neos.Fusion:Reduce {
(and same for bar)