Text element: Rich Text / inline editing breaks Twig and Dynamic Content (follow-up)

Hi team,

this is a follow-up to my thread Dynamic Content in html attribute from October 2024 – I think I found the root cause, and it now hits Twig too.

What happens

I have a Text element with a bit of Twig logic, written in HTML mode:

{% if {{dc:fortuna:longest_chain}} < 5 %}…{% endif %}

It works fine until the text passes through the rich text editor. After that the < is saved as &lt; and the page shows “Could not render Twig template: Unexpected character “&””. Last year it was the quotes inside a style attribute with {{dc:global:color …}} .

Why (as far as I can tell from the builder bundle)

Both Rich Text mode and inline editing run the content through TinyMCE and save editor.getContent() . TinyMCE re-serializes the HTML, so < in text becomes &lt; and attribute quotes get rewritten. Inline editing even saves on click-outside when nothing was changed.

Suggestion

If the content contains {{ or {% , skip TinyMCE (stay in HTML mode, no inline editing) – or at least only save back when the user actually changed something.

For now I work around it by avoiding < / > in Twig and by using the Raw Content element for texts with Dynamic Content.

Thanks!