Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Renderer.php

function Renderer::doReplacePlaceholder

Replaces a placeholder with its markup.

Parameters

string $placeholder: The placeholder HTML.

\Drupal\Component\Render\MarkupInterface|string $markup: The markup to replace the placeholder with.

array $elements: The render array that the placeholder is from.

array $placeholder_element: The placeholder element render array.

Return value

\Drupal\Component\Render\MarkupInterface|string The rendered HTML.

2 calls to Renderer::doReplacePlaceholder()
Renderer::renderPlaceholder in core/lib/Drupal/Core/Render/Renderer.php
Renders final HTML for a placeholder.
Renderer::replacePlaceholders in core/lib/Drupal/Core/Render/Renderer.php
Replaces placeholders.

File

core/lib/Drupal/Core/Render/Renderer.php, line 165

Class

Renderer
Turns a render array into an HTML string.

Namespace

Drupal\Core\Render

Code

protected function doReplacePlaceholder(string $placeholder, string|MarkupInterface $markup, array $elements, array $placeholder_element) : array {
    // Replace the placeholder with its rendered markup, and merge its
    // bubbleable metadata with the main elements'.
    $elements['#markup'] = Markup::create(str_replace($placeholder, $markup, $elements['#markup']));
    $elements = $this->mergeBubbleableMetadata($elements, $placeholder_element);
    // Remove the placeholder that we've just rendered.
    unset($elements['#attached']['placeholders'][$placeholder]);
    return $elements;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal