Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active January 22, 2018 10:32
Show Gist options
  • Save mficzel/dbd19a4584be71c05670da0e5d680762 to your computer and use it in GitHub Desktop.
Save mficzel/dbd19a4584be71c05670da0e5d680762 to your computer and use it in GitHub Desktop.
Fusion Node Mapping
#
# ATTENTION UNTESTED PSEUDO-CODE TO SHOW THE PRINCIPLE IDEA
#
# THIS DOES NOT WORK YET
#
prototype(Neos.Fusion:RawCollection) {
// store __node reference in the rendered result
// if item is a node and the value is an array
itemRenderer.@process.addNodeReference {
@if.itemIsNode = ${q(item).is('[instanceof Neos.Neos:Node]')}
@if.valueIsArray = ${Type.isArray(value)}
expression = ${Array.concat(value, [__node: item])}
}
}
prototype(Neos.Fusion:Collection) {
// apply content element wrapping to all items with __node meta property
itemRenderer.@process.applyContentElementWrapping {
@if.itemIsArray = ${Type.isArray(this[itemName])}
@if.itemHasNode = ${item.__node && q(this[itemName].__node).is('[instanceof Neos.Neos:Node]')}
expression = Neos.Neos:ContentElementWrapping {
node = ${this[itemName].__node}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment