Bug with twig use in parameters in components

I have come across a bug with using twig within components, where a headline element is nested within a div element, and the div element is being exported as a component.

In this instance, having a headline element pull through the parameters from the div component with twig (e.g. {{ p.text }}), and twig data passed into the component in a page is not being parsed, and is outputting nothing in the Cornerstone preview, and twig text in on the frontend ( {{ looper.index }} etc)

This occurs when using the component in a looper that is being fed by dynamic content from a parameter.

I have set up a testing environment to troubleshoot this bug and eliminate other issues that might be going on.
You can see the page here: https://components.odb.host/component-twig-bug/ and I will add login details to a secure note.

Is there any way you could increase the RAM on that site? I can’t export a document on that site due to this. And I couldn’t recreate the bug on my own. Have a great weekend.

Unfortunately not as SiteGround does not allow increasing the memory_limit of any sites, and adjusting WP_MEMORY_LIMIT did not fix the issue with exporting a document.

[03-Feb-2025 17:50:21 UTC] PHP Fatal error:  Allowed memory size of 805306368 bytes exhausted (tried to allocate 262144 bytes) in /home/customer/www/components.odb.host/public_html/wp-content/themes/pro/cornerstone/includes/classes/Templating/Export.php on line 109
[03-Feb-2025 17:50:43 UTC] PHP Fatal error:  Allowed memory size of 805306368 bytes exhausted (tried to allocate 262144 bytes) in /home/customer/www/components.odb.host/public_html/wp-content/themes/pro/cornerstone/includes/classes/Templating/Export.php on line 109
[03-Feb-2025 17:52:11 UTC] PHP Fatal error:  Allowed memory size of 805306368 bytes exhausted (tried to allocate 67108872 bytes) in /home/customer/www/components.odb.host/public_html/wp-content/themes/pro/cornerstone/includes/classes/Templating/Export.php on line 128
[03-Feb-2025 17:52:51 UTC] PHP Fatal error:  Allowed memory size of 805306368 bytes exhausted (tried to allocate 67108872 bytes) in /home/customer/www/components.odb.host/public_html/wp-content/themes/pro/cornerstone/includes/classes/Templating/Export.php on line 128
[03-Feb-2025 17:53:09 UTC] PHP Fatal error:  Allowed memory size of 1015021568 bytes exhausted (tried to allocate 262144 bytes) in /home/customer/www/components.odb.host/public_html/wp-content/themes/pro/cornerstone/includes/classes/Templating/Export.php on line 109
[03-Feb-2025 17:53:33 UTC] PHP Fatal error:  Allowed memory size of 1434451968 bytes exhausted (tried to allocate 262144 bytes) in /home/customer/www/components.odb.host/public_html/wp-content/themes/pro/cornerstone/includes/classes/Templating/Export.php on line 109

I initially thought the issue might be isolated to one website, and something else conflicting with things there, but I was able to re-create it on a new fresh install and have narrowed it down to the component needing having a group in the parameters.

i.e. if the text is populated by p.text then it works as expected, but if it is populated by p.setup.text then it breaks and shows the {{ looper.item.title }}.

I have set up a new testing site: https://twig-bug.odb.host/untitled-page/
With the same login details as before, and exporting the page seems to work now if you need to do that.

Hope this helps get to the bottom of the issue!

1 Like

I appreciate the example. I can get that fixed in the beta.

Have a great day.

1 Like

Fab, thanks!

Do you need the second demo site at twig-bug.odb.host up and running still, or will I be okay to destroy that now?

You can destroy that site now. Thanks again.

1 Like

@connexxions I’ve had similar bugs, but what helped me was doing the dynamic content syntax (ie: {{dc:p:setup.text}} or {{dc:param:setup.text}})
(the second p or param is interchangable, also no spaces in in curly braces)

From the docs that I read it was something along the lines of twig not currently processing arrays or something, but then {{looper.item.title}} works, so idk. Maybe try the dc route

edit: updated syntax

In the docs the arrays refer to the Dynamic Content looper for clarification. You’ll notice it doesn’t output Twig there if you have Twig enabled. Using the json_encode filter with a JSON looper provider can setup an looper based on Twig results. Arrays items in Twig can be accessed like you said through a .. Have a great day.

image

image