function Renderer::renderPlaceholder
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::renderPlaceholder()
- 10 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::renderPlaceholder()
- 11.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::renderPlaceholder()
Overrides RendererInterface::renderPlaceholder
1 call to Renderer::renderPlaceholder()
- Renderer::replacePlaceholders in core/
lib/ Drupal/ Core/ Render/ Renderer.php - Replaces placeholders.
File
-
core/
lib/ Drupal/ Core/ Render/ Renderer.php, line 167
Class
- Renderer
- Turns a render array into an HTML string.
Namespace
Drupal\Core\RenderCode
public function renderPlaceholder($placeholder, array $elements) {
// Get the render array for the given placeholder
$placeholder_elements = $elements['#attached']['placeholders'][$placeholder];
// Prevent the render array from being auto-placeholdered again.
$placeholder_elements['#create_placeholder'] = FALSE;
// Render the placeholder into markup.
$markup = $this->renderPlain($placeholder_elements);
// 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_elements);
// Remove the placeholder that we've just rendered.
unset($elements['#attached']['placeholders'][$placeholder]);
return $elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.