title: Twig extension disable auto escape
body: <p>I made a twig extension to be able to call functions in the templates, but unfortunately now the rendered html content of these functions is escaped. Do you have any idea how I could disable that?</p>
  
  <p>FrontendTwigExtension.php</p>
  
  <pre><code>class FrontendTwigExtension extends Twig_Extension
  {
  /**
   * @var DataProviderService
   */
  private $dataProvider;
  
  /**
   * FrontendTwigExtension constructor.
   * @param DataProviderService $dataProvider
   */
  public function __construct(DataProviderService $dataProvider)
  {
      $this-&gt;dataProvider = $dataProvider;
  }
  
  /**
   * @return array
   */
  public function getFunctions(): array
  {
      return array(
          new Twig_Function('getProductDetailData',
              [$this, 'getProductDetailData'],
              ['needs_environment' =&gt; true]
          ),
          new Twig_Function('getPageHeader',
              [$this, 'getPageHeader'],
              ['needs_environment' =&gt; true]
          )
      );
  }
  
  /**
   * @param Twig_Environment $env
   * @return string
   * @throws Twig_Error_Loader
   * @throws Twig_Error_Runtime
   * @throws Twig_Error_Syntax
   */
  public function getPageHeader(Twig_Environment $env): string
  {
      return $env-&gt;render('Component/PageHeader/pageHeader.html.twig');
  }
  
  /**
   * @param Twig_Environment $env
   * @return string
   * @throws Twig_Error_Loader
   * @throws Twig_Error_Runtime
   * @throws Twig_Error_Syntax
   */
  public function getProductDetailData(Twig_Environment $env): string
  {
      $service = new ProductDetailDataService($this-&gt;dataProvider);
      return $env-&gt;render('Module/ProductDetailPage/productDetailData.html.twig',
          [
              'productData' =&gt; $service-&gt;getData()
          ]
      );
  }
  }
  </code></pre>
  
  <p>template.html.twig</p>
  
  <pre><code>{% extends 'base.html.twig' %}
  {% block pageHeader %}
      {{ getPageHeader() }}
      {{ getProductDetailData() }}
  {% endblock %}
  </code></pre>
  
  <p>services.yaml</p>
  
  <pre><code>App\Extension\FrontendTwigExtension:
      arguments:
          - '@App\DataProvider\DataProviderService'
      tags:
          - { name: 'twig.extension' }
  </code></pre>