You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've stumbled over a crash in the CP which I reported here. And I wasn't the first one who stumbled over this issue (see #248). Turns out the problem gets caused by my custom module code that I got from the docs. I've only registered custom Twig functions if the current request is a site request.
And I've done this many years ago. This is the type of code you write once and never touch again for many years because "it just works". That's why I would have never found this on my own.
Now it turns out there are multiple instances where this check causes a problem and the biggest one isn't even mentioned in the docs: Twig functions are also required in the CP if you nest partial templates in CKEditor and render them in the cards. According to this issue this is expected behavior since Craft 4.2.0.
And here's my main issue: I absolutely don't understand why.
I understood it if the partial Twig templates get used under all circumstances in those cards – or not at all. But they only get used after one level of nesting. The top level card doesn't use Twig at all. But if that card renders a nested partial it switches to Twig rendering for that nested partial only. This seemed like a bug to me at first.
On top of that I understood the switch to Twig rendering if it caused the content of the nested partial to render nicely. But it all gets squeezed together into a single paragraph, which is barely readable. There's not even a space added between two paragraphs.
The following text in a nested partial that itself renders a CKEditor field:
Level 1 CKEditor.
Level 2 CKEditor. How are you?
I'm fine.
Back to level 1.
And more text.
renders as:
Level 1 CKEditor. Level 2 CKEditor. How are you?I'm fine. Back to level 1.And more text.
Notice the missing space after "How are you?" and "Back to level 1.".
That's why I'm wondering: Why is Twig being used for level 2 but not level 1? Both render the same way. Twig doesn't make a change here. Can someone at least explain the rationale behind this behavior? Thank you very much.
I also think that the content of templates that are meant to be used for the website should not be allowed to crash the CP. That's a type of interaction that I just don't expect to happen. At least those exceptions should be caught, right?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I've stumbled over a crash in the CP which I reported here. And I wasn't the first one who stumbled over this issue (see #248). Turns out the problem gets caused by my custom module code that I got from the docs. I've only registered custom Twig functions if the current request is a site request.
And I've done this many years ago. This is the type of code you write once and never touch again for many years because "it just works". That's why I would have never found this on my own.
Now it turns out there are multiple instances where this check causes a problem and the biggest one isn't even mentioned in the docs: Twig functions are also required in the CP if you nest partial templates in CKEditor and render them in the cards. According to this issue this is expected behavior since Craft 4.2.0.
And here's my main issue: I absolutely don't understand why.
I understood it if the partial Twig templates get used under all circumstances in those cards – or not at all. But they only get used after one level of nesting. The top level card doesn't use Twig at all. But if that card renders a nested partial it switches to Twig rendering for that nested partial only. This seemed like a bug to me at first.
On top of that I understood the switch to Twig rendering if it caused the content of the nested partial to render nicely. But it all gets squeezed together into a single paragraph, which is barely readable. There's not even a space added between two paragraphs.
The following text in a nested partial that itself renders a CKEditor field:
renders as:
Notice the missing space after "How are you?" and "Back to level 1.".
That's why I'm wondering: Why is Twig being used for level 2 but not level 1? Both render the same way. Twig doesn't make a change here. Can someone at least explain the rationale behind this behavior? Thank you very much.
I also think that the content of templates that are meant to be used for the website should not be allowed to crash the CP. That's a type of interaction that I just don't expect to happen. At least those exceptions should be caught, right?
All reactions