public static function InlineTemplate::preRenderInlineTemplate

public static InlineTemplate::preRenderInlineTemplate($element)

Renders a twig string directly.

Parameters

array $element:

Return value

array

File

core/lib/Drupal/Core/Render/Element/InlineTemplate.php, line 49

Class

InlineTemplate
Provides a render element where the user supplies an in-line Twig template.

Namespace

Drupal\Core\Render\Element

Code

public static function preRenderInlineTemplate($element) {
  /** @var \Drupal\Core\Template\TwigEnvironment $environment */
  $environment = \Drupal::service('twig');
  $markup = $environment->renderInline($element['#template'], $element['#context']);
  $element['#markup'] = $markup;
  return $element;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!InlineTemplate.php/function/InlineTemplate::preRenderInlineTemplate/8.1.x