Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active May 28, 2021 06:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mficzel/5c9c8e54f5a327123f07d762b34e2053 to your computer and use it in GitHub Desktop.
Save mficzel/5c9c8e54f5a327123f07d762b34e2053 to your computer and use it in GitHub Desktop.
Wrapper components
prototype(Vendor.Site:Example) < prototype(Neos.Fusion:Component) {
foo = null
bar = null
renderer = Neos.Fusion:Component {
# pass all outer props to the renderer
@apply.props = ${props}
# alternatively pass explicit props to the renderer
foo = ${props.foo}
# calculate additional props based on outer props
barTransformed = Neos.Fusion:Map {
items = ${props.bar}
itemRenderer = ...
}
renderer = afx`...`
}
}
@bwaidelich
Copy link

Just for the record, an alternative syntax using @context:

prototype(Vendor.Site:Example) < prototype(Neos.Fusion:Component) {
  foo = null
  bar = null
  renderer.@context {
    foo = ${props.foo}
    barTransformed = Neos.Fusion:Map {
      items = ${props.bar}
      itemRenderer = ...
    }
  }
  renderer = afx`...`
}

@mficzel
Copy link
Author

mficzel commented Apr 3, 2020

That is not exactly equivalent as @context is available in the whole chain below while props are evaluated fresh for each component.
In usual cases it may look equivalent but has some important deviations.

@bwaidelich
Copy link

OK, good call. I like the brevity of it, but it's not the same you're right

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