[D11] Embedded Blocks in REST Export Views return <drupal-render-placeholder> tags

Created on 22 September 2025, 27 days ago

Problem/Motivation

In Drupal 11, when a content field (e.g., a "Body" field managed by CKEditor 5) contains an embedded block (e.g., a Views block displaying recent articles), and this content is exposed via a Views REST Export display, the JSON output returns <drupal-render-placeholder> tags instead of the rendered HTML for the embedded block.

For example, if a basic page's body field embeds a "Recent Articles" Views block, accessing a REST endpoint for that basic page will show a placeholder like this:

<div data-entity-type="block" ... class="embedded-entity"><drupal-render-placeholder callback="Drupal\\block\\BlockViewBuilder::lazyBuilder" arguments="..." token="..."></drupal-render-placeholder></div>

This issue prevents decoupled frontends or other API clients from consuming the actual content of embedded blocks, as they receive unrendered placeholder tags. The same content, when viewed in the Drupal UI (e.g., in the Views preview or on the basic page itself), correctly renders the embedded block's HTML.

This behavior is observed in Drupal 11 (specifically D11.2.4) but was not present in Drupal 10.4.8, indicating a change in render placeholder handling within REST contexts.

Steps to reproduce

  1. Install and enable the entity_embed module.
  2. Configure an embed button for blocks at `/admin/config/content/embed`.
    • Set "Embed type" to "Entity".
    • Set "Entity Type" to "Block".
    • Ensure "Allowed Entity Embed Display plugins" includes "Rendered Entity".
  3. Add this embed button to the "Full HTML" CKEditor 5 text format at `/admin/config/content/formats/manage/full_html`.
  4. Enable the "Display embedded entities" filter for the "Full HTML" text format.
  5. Create a new Views block display (e.g., a block showing "Recent Articles" from a content type like "Article").
  6. Place this new Views block in a region via the Block layout (e.g., `admin/structure/block`). *This step is crucial for the block to be discoverable and renderable.*
  7. Create a new Basic Page content. In the CKEditor 5 "Body" field, use the Entity Embed button to embed the Views block created in step 5. Save the content.
  8. Create a new View with a REST Export display (e.g., path: `/api/content_endpoint`).
    • Configure it to show "Content" of type "Basic page".
    • Add the "Body" field to the REST export, ensuring it uses a "Processed text" or "Default" formatter.
  9. Access the REST endpoint in a browser or tool like Postman.
  10. Observe the JSON output: the "Body" field will contain a <drupal-render-placeholder> tag for the embedded Views block instead of the list of articles.
  11. In contrast, navigating to the Views preview within Drupal, or viewing the basic page directly, correctly displays the rendered HTML of the embedded block.

Proposed resolution

The issue appears to stem from a specific line of code introduced or significantly altered in Drupal 11 within core/modules/block/src/BlockViewBuilder.php.

Specifically, the following code snippet forces the creation of a render placeholder:

        if ($plugin->createPlaceholder()) {
          $build[$entity_id] += [
            '#create_placeholder' => TRUE,
          ];
        }

When this conditional block is removed or commented out, the REST endpoint correctly returns the rendered HTML of the embedded block, resolving the issue for API consumers.

The attached patch implements this by commenting out the problematic lines in BlockViewBuilder.php.

API changes

  • Blocks will no longer be marked with #create_placeholder => TRUE by default in their render array during the `BlockViewBuilder::lazyBuilder` process. Modules or custom code explicitly checking for this render array property to trigger specific asynchronous rendering behaviors might be affected.
🐛 Bug report
Status

Active

Version

11.2 🔥

Component

block.module

Created by

🇮🇳India someshver Panchkula

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

Comments & Activities

Not all content is available!

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

No activities found.

Production build 0.71.5 2024