Even though Shopify have announced Include is deprecated you can still use include, I personally I think it's more powerful than render.
{% include 'snippet.liquid' %}
Has to pass variable into the snipped using include:
1. Assign variables before you call the snippet:
{% assign fulfstat = order.fulfillment_status %}{% assign finstat = order.financial_status %}
{% include 'check-order-status'
2.
{% include 'check-order-status', fulfstat: order.fulfillment_status, finstat: order.financial_status %}
Content inside the snipped:
{%- capture fulfillment_status -%}
{%- if fulfstat == 'fulfilled' -%}
bg-primary
{%- elsif fulfstat == 'unfulfilled'-%}
bg-danger
{%- else -%}
bg-dark
{%- endif -%}
{%- endcapture -%}
{%- capture financial_status -%}
{%- if finstat == 'paid' -%}
bg-success
{%- elsif finstat == 'partially_refunded'-%}
bg-warning
{%- else -%}
bg-secondary
{%- endif -%}
{%- endcapture -%}
Include works in both ways, and, you can use variable within the snippet outside of that snippet
{{ financial_status }}
{{ fulfillment_status }}
{% render 'snippet.liquid' %}
I have tested render and you can pass variable to the snippet like this:
{% include 'check-order-status', fulfstat: order.fulfillment_status, finstat: order.financial_status %}
But then, you can't use {{ financial_status }} {{ fulfillment_status }} inside of that snippet.
So far this is the difference I noticed between include and render
0 comments