Support ServerSideRender component

Created on 14 March 2021, over 3 years ago
Updated 20 December 2023, 6 months ago

Problem/Motivation

Gutenberg's ServerSideRender component can be used to render dynamic blocks in the editor. Currently it is not supported since the Wordpress URL to render a block has not been integrated.

Proposed resolution

Attached patch adds a route to render a dynamic block and maps it to the URL Wordpress uses for the ServerSideComponent. The component can now be used like so:

const ServerSideRender = wp.serverSideRender;

function render() {
  <ServerSideRender
    block="myblocks/foo"
    attributes={ {
      title: "Foo",
      attr2: "Value of attr2"
    } }
  />
}

This will render the block via a fetch, using the template defined for dynamic block `myblocks/foo` (e.g. `gutenberg-block--myblocks--foo.html.twig`). PS ensure `myblocks/foo` is an entry under `dynamic-blocks:` in your custom module's `.gutenberg.yml`.

Other options for the component are detailed at https://developer.wordpress.org/block-editor/reference-guides/packages/p...

πŸ’¬ Support request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada bgilhome Victoria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024