Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello everyone,
I've come across a changelog that notes the {% include %} tag is being deprecated in favour of the new {% render %} tag. I'm aware that previous include tags are keeping their functionality, but the new render tag must be included going forward.
The way in which we render our content on pages that aren't the homepage is using a single section that contains the fields for every content block we have. Then we loop through these block and include the required snippet like so:
{% for section in section.blocks %} {%- assign snippet_name = 'section-' | append: section.type -%} {% include snippet_name %} {% endfor %}
However, it seems to not allow me to use a variable in place of the string or allow the snippet access to the data in the parent section which will completely break the site using our current strategy.
Do you have any recommendations on how to solve this issue? Are there new updates coming that will make this change make sense?
Any help would be greatly appreciated!
Hi Matt_Cottis,
try using capture instead of assign:
{% for section in section.blocks %} {%- capture snippet_name -%}section-{{ section.type }}{%- endcapture -%} {% include snippet_name %} {% endfor %}
This works fine for me.
Regards,
Daniel
Hi Leina,
Thank you for replying, but this is an old post that I thought was deleted, here's the new post for reference: https://community.shopify.com/c/Technical-Q-A/Deprecated-include-tag/td-p/608267
Found this workaround. By appending a string (even empty) it transforms the variable into a string.
{%- render variable_name | append: ".liquid" -%}
or
{%- render variable_name | append: "" -%}
Found on this thread.
https://community.shopify.com/c/shopify-design/how-can-i-render-a-snippet-this-name-is-defined-by-a-...
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024