Verwendung: Ausgabe im twig template wenn tinyMCE angewendet wird

Bennie's Avatar

Bennie

May 14, 2024 @ 01:07 PM

Produkt: Custom Elements Contao
Contao-Version: 5.3

Ist es richtig, dass in einem twig template die Variable mit dem raw Filter eingetragen werden muss, um keine HTML Tags mit auszugeben, wenn man den tinyMCE nutzt .
 Ich habe in der einer rsce_test_config.php z.B. so etwas:

       'text' => [
            'label' => ['Text', 'Hilfetext...'],
            'inputType' => 'textarea',
            'eval' => [
                'mandatory' => false,
                'rte' => 'tinyMCE',
            ],
        ],

im Template rsce_test.html.twig dann das
{% if text %}
    <div> {{ text|raw}}</div>
{% endif %}

Lasse ich raw weg wird <p></p> vom tinyMCE mit ausgegeben. Ist das so richtig umgesetzt, also muss man immer raw nutzen in diesem Fall oder hab ich da einen Fehler gemacht?

  1. Support Staff 1 Posted by RockSolid Theme... on May 16, 2024 @ 03:05 PM

    RockSolid Themes's Avatar

    Vielen Dank für Ihre Frage.

    Ja, die Verwendung von |raw ist für tinyMCE-Eingabefelder korrekt. Weitere Informationen dazu finden Sie in der Dokumentation von Contao: https://docs.contao.org/dev/framework/templates/architecture/#encoding

Reply to this discussion

Internal reply

        No formatting (switch to Markdown)

          You can attach files up to 10MB

          If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

            Keyboard shortcuts

            Generic

            ? Show this help
            ESC Blurs the current field

            Comment Form

            r Focus the comment reply box
            ^ + ↩ Submit the comment

            You can use Command ⌘ instead of Control ^ on Mac