Question

when trying to ouput HTML with Twig (and FuelPHP), I get escaped HTML, even when autoescape value is to false (config file or directly in the template...)

Here's my Twig template:

{% set id_page = 'visio_page' %}
{% include 'layout/header.twig' %}
    <div id="main">
        <div class="inner">
        {% autoescape false %} 
            {{form}} {# or form|raw #}
        {% endautoescape %}
        </div>
    </div>
{% include 'layout/footer.twig' %}

Here's my form variable I give to Twig:

$data['form'] = $fieldset->form()->build(Uri::create('/form/submit'));
//output is only HTML: '<form>......</form>';

That is the result I have... The result show only escaped HTML, not form.

I usually use {{my_var|raw}} but it does not work in this particular case ...

Was it helpful?

Solution

Fuel escapes the values to views by default. And the default config is below:

'auto_encode' => true;  // (Fuel's auto escaping)
'autoescape'  => false; // (Twig's auto escaping)

enter image description here

If you want to change, copy fuel/packages/parser/config/parser.php to fuel/app/config directory, and change them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top