0

Hey guys i have something odd happening and I don't understand why:

The opening of my template i set a variable {% set text = component.textarea ?? null %}

Lower in my template i have the following: {% set text = include('_components/_dataTypes/textarea') %}

That template only currently has {{ text }} in it so as of right now doesn't mean much.

Then last in my template i have {{ text|raw }}

However characters are still encoded.

I've found that if i remove the include template, even though all it includes is {{ text }} that |raw works. I should note that if i put |raw in the include template, it still does not work.

Why is that? Is it a parse order thing or what's going on there that causes the include to ignore the filter? I should note that using Wordsmith and the |pde filter does work regardless of the include... however characters such as < > ' " etc. are still encoded, where as they are not without the include.

Please help me understand why this is occurring. Thank you.

| improve this question | | | | |
  • I was asked if i am using Javascript at all in any of these places or if it is all Twig/HTML. The answer is there is ZERO javascript, it is strictly html/twig. – Christopher Healey Mar 15 at 10:47
  • 1
    Interesting, in all these years I'd never considered setting a variable using the return value of an include. I didn't even know it was possible! I see how that could be helpful, though maybe a macro or embed would work around any parse order issues. – James Smith Mar 16 at 9:22
1

As mentioned in the Discord you are probably looking for the source function.

The reason the include doesn't work is covered in the old PR for (what eventually became) source. It's probably best I link all that discussion than try to put it in my own words here!

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.