function InlineTemplate::preRenderInlineTemplate

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

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;
}

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