-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass content to block render callback #6239
Pass content to block render callback #6239
Conversation
It might be useful to pass the One aspect to consider (although not a blocker): if someone is using an existing shortcode render callback for their dynamic block, this could have unintended consequences. |
If we removed them can we share a justification to bring them back as well as an explanation at a high-level on how this PR addresses the needs that provoked taking the content out in the first place? |
This reverts commit 1fb516a.
I've updated this code to also pass the block name to the render callback, taking code from #4673 The justification for bringing this back?
Why was this removed in the first place? It's not completely clear to me from the pull request in which it was removed (#4591). Is the concern is that for a dynamic block with nested content, the nested content is not parsed into blocks? It would be up to your code to handle calling |
Passing the block name would also be useful if you are trying to create a generic render callback that handles a few block types. My use case here is that the This functionality is achievable with a closure. RE @danielbachhuber's concerns:
What are your concerns? That the value of |
@aduth maybe you can provide some historical context here. I'd like to avoid making slinky-commits to undo and redo changes different people are making. @mattheu to note, I think dynamic blocks should have their content, but I want to make sure we don't skip over something we are unaware of because we didn't ask. |
d9db075
to
3e1301c
Compare
The behavior prior to #4591 was such that displaying a post on the front-end consisted of reconstructing all of block content from the parsed object. This is why I don't have an issue with making more available to the render callback. What I might propose is:
|
Also tangentially related is #6170 |
Updated following suggestions by @aduth
|
I meant to include an example, but I was lazy. I'll include one now:
Based on the current pull request, |
Rather than provide content as a string, it should be an array of child blocks and boundary html, so that dynamic blocks can potentially contain children. This would be crucial to fully match the functionality currently available with shortcodes. This would be needed for functions like a "members only" block, which would render child blocks only if the current user is a specific role, or a "conditional content" block, where different child blocks would be shown depending on custom conditionals. |
Somewhat random, but if and as we incorporate attribute parsing on the server side as well the |
Description
See #5760
Support for passing of a blocks content to the render block was removed in #4591
How has this been tested?
Types of changes
This is not a breaking change.
It simply passes the block content to the render callback as the second param, in addition to the attributes which are passed currently.
For self closing blocks, this will always be an empty string.
Checklist: