function RendererInterface::renderPlain

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/RendererInterface.php \Drupal\Core\Render\RendererInterface::renderPlain()
  2. 10 core/lib/Drupal/Core/Render/RendererInterface.php \Drupal\Core\Render\RendererInterface::renderPlain()
  3. 11.x core/lib/Drupal/Core/Render/RendererInterface.php \Drupal\Core\Render\RendererInterface::renderPlain()

Renders final HTML in situations where no assets are needed.

Calls ::render() in such a way that placeholders are replaced.

Useful for instance when rendering the values of tokens or emails, which need a render array being turned into a string, but do not need any of the bubbleable metadata (the attached assets and cache tags).

Some of these are a relatively common use case and happen *within* a ::renderRoot() call, but that is generally highly problematic (and hence an exception is thrown when a ::renderRoot() call happens within another ::renderRoot() call). However, in this case, we only care about the output, not about the bubbling. Hence this uses a separate render context, to not affect the parent ::renderRoot() call.

(Can be executed within another render context: it runs in isolation.)

Parameters

array $elements: The structured array describing the data to be rendered.

Return value

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

See also

\Drupal\Core\Render\RendererInterface::renderRoot()

\Drupal\Core\Render\RendererInterface::render()

1 method overrides RendererInterface::renderPlain()
Renderer::renderPlain in core/lib/Drupal/Core/Render/Renderer.php
Renders final HTML in situations where no assets are needed.

File

core/lib/Drupal/Core/Render/RendererInterface.php, line 62

Class

RendererInterface
Defines an interface for turning a render array into a string.

Namespace

Drupal\Core\Render

Code

public function renderPlain(&$elements);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.