By editor, 4 June, 2016 Question How to use the inline templating system (inline_template) of drupal 8 render array with a inline twig template ? Example 1. Basic inline template $output[] = [ '#type' => 'inline_template', '#template' => '{{ yourvar }}', '#context' => [ 'yourvar' => 'The Value', ], ]; return $output; Example 2. Display a basic value and a raw HTML $output[] = [ '#type' => 'inline_template', '#template' => '{{ yourvar }} {{ yourhtml | raw }}', '#context' => [ 'yourvar' => 'Your Var', 'yourhtml' => '<span style="color:red;">Your HTML</span>', ], ]; return $output; Tags Drupal 8 Code Theming Twig Comments You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Text format Plain textBasic_html Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically.
Comments