Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Over the past year I've seen 'render' pop-up in liquid but haven't taken any notice of but I've than 'include' is now depreciated so I have a couple of questions.
How long will 'include' work for before I begins to break websites?
And I have many multi-regional clients with stores for USA, EU, Australia etc so I often have a 'if-store.liquid' snippet which I use to define global variables eg.
{%- if shop.name contains 'United States' -%}
{%- assign store_location = 'US' -%}
{%- assign klaviyo_list = 'X' -%}
{%- elsif shop.name contains 'Australia' -%}
{%- assign store_location = 'AU' -%}
{%- assign klaviyo_list = 'X' -%}
{%- else -%}
{%- assign store_location = 'NZ' -%}
{%- assign klaviyo_list = 'X' -%}
{%- endif -%}
This is so I can drop it into various templates and sections with an include tag but render will obviously break this functionality, so I wonder if there is a better/alternative way I should be doing this in the future?
This is kind-of a bump but I'm also surprised now one else seems so having any issues with exporting variables from render tags.
Another example I have is that I use a reusable 'size-conversion' snippet to convert sizes:
{%- assign var_title = item.variant.options[i] -%}
{%- include 'size-conversion' -%}
{{ var_title }}
And in the 'size-conversion' snipped I have a conversion logic eg:
{%- if store_location == "eu" -%}
{%- assign var_title = var_title | replace: '28','38' | replace: '30','40' | replace: '32','42' | replace: '34','44' | replace: '36','46' -%}
{%- endif -%}
When/if 'include' is removed there will be no way to achieve this so it would be great if there was a way to export or use a variable outside of a render tag.
Maybe this isn't an widely discussed issue yet because we can still use include but I'd like to find a solution to this and start transitioning to render before its too late.
I totally agree with you. I have a use case for using a variable defined in a snippet. I decided to stick with include until it's fully sunset. For now I couldn't find a way with render.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024