Drupal 8 - Controller mit inline Template (Twig, HTML | raw)

Submitted by Gast (nicht überprüft) on Do, 08/20/2020 - 14:24

Controller könnte so aussehen:

<?php

namespace Drupal\my_custom_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\node\NodeInterface;
use Drupal\node\Entity;
use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;

/**
 * Class MyTestController.
 */
class MyTestController extends ControllerBase {

    public function main(){




        $my_html = '
        <p>Some <i>HTML</i> Code</p>
             
        ';


        return [
            '#type' => 'inline_template',
            '#template' => '{{ myvar1|raw }}',
            '#context' => [
                'myvar1' => $my_html 
            ]
        ];
    }


}

 

Neuen Kommentar schreiben

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.