Skip to content
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

ServerSideRender does not expose block's content #10478

Open
barryceelen opened this issue Oct 10, 2018 · 3 comments
Open

ServerSideRender does not expose block's content #10478

barryceelen opened this issue Oct 10, 2018 · 3 comments
Labels
[Package] Server Side Render /packages/server-side-render [Type] Enhancement A suggestion for improvement.

Comments

@barryceelen
Copy link
Contributor

barryceelen commented Oct 10, 2018

The block's HTML is passed along to the render function of a dynamic block. When using ServerSideRender the block's HTML is not made available to the render function, only it's attributes are passed along via the API request:

https://github.com/WordPress/gutenberg/blob/master/lib/class-wp-rest-block-renderer-controller.php#L149

One can access the block's HTML via the block's attributes (that would enable me to pass the html to the render function by adding it to the attributes), but that html content does not include nested blocks as they are within HTML comments:

content: {
	type: 'string',
	source: 'html',
},

I've tried accessing the block's "raw" unparsed HTML in my edit function but have not found a way to do so, is this exposed in any way?

@aduth
Copy link
Member

aduth commented Oct 10, 2018

Can you confirm whether this is a duplicate of #8214 ? (Discussion ongoing in #8760)

@aduth aduth added the [Status] Needs More Info Follow-up required in order to be actionable. label Oct 10, 2018
@barryceelen
Copy link
Contributor Author

barryceelen commented Oct 10, 2018

Thanks @aduth, this is not a duplicate of #8214

Context:

I'm creating a block preview using <ServerSideRender />. The block uses the php render callback to parse the block's saved HTML content.

The block's content is made available as $inner_content to the render function (in addition to the block's attributes) when rendering it in the theme's template:
https://github.com/WordPress/gutenberg/blob/master/lib/blocks.php#L240

But the content is not available (only the block's attributes) when rendering the block via ServerSideRender:
https://github.com/WordPress/gutenberg/blob/master/lib/class-wp-rest-block-renderer-controller.php#L149

@aduth aduth added [Package] Server Side Render /packages/server-side-render and removed [Status] Needs More Info Follow-up required in order to be actionable. labels Oct 10, 2018
@fabiankaegy
Copy link
Member

I am also running into this issue. There is no way to pass the InnerBlocks html string to the block renderer Rest endpoint. Which is something that I believe would be very useful.

The Endpoint /wp/v2/block-renderer/${ block } takes the blocks attributes as query args, but not the InnerBlocks markup string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Server Side Render /packages/server-side-render [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants