Removal of theme snippets

Solved
Shopify Partner
34 1 10

According to the Unite talks, when the new OSDE launches with Sections Everywhere, the new themes will no longer be able to use snippets, which I get. But my main problem is snippets hold so much more than just reusable content, I use snippets for logical code too for things like responsive images and customer tag checking.

 

Naturally, it wouldn't make any sense whatsoever to use an entire section for simply checking customer tags, so how will this be utilised? I'd really rather not have to copy/paste this code all over my themes and then somehow maintain each of them when a change is made, so in real-life scenarios, what will be the expected functionality here?

Liam Merlyn | Shopify Developer
2 Likes
Shopify Expert
537 24 97

I think they mentioned in the Q&A (https://youtu.be/HlpOGQrRBPY?t=1318) that they're looking into replacing snippets with something equivalent for the development workflow, so something that would be part of the theme build toolchain.

 

Here's the timestamp where they go into snippets specifically: https://www.youtube.com/watch?v=HlpOGQrRBPY&feature=youtu.be&t=1580

★ ThemeUp: Nifty Upgrades for your Shopify Store ★ https://themeup.net
0 Likes
New Member
1 0 0

A tool that only compiles snippets at build time is not really an acceptable solution, unfortunately. A ton of people work on customizing existing/paid themes, and theme developers almost never provide the full source.

0 Likes

Success.

Shopify Staff
Shopify Staff
9 1 18

Following Unite we gathered feedback and re-assessed our plans. Frame, page and content sections will be able to use snippets after all, but will do so via a new Liquid tag, different than {% include %}, which will add some constraints on how snippets are used. The constraints are intended to make our online store platform faster, more reliable, and easier to work with. The new Liquid tag will be released shortly.

6 Likes
Shopify Staff
Shopify Staff
9 1 18

The replacement for the {% include %} Liquid tag has been released: {% render %}.

3 Likes
Shopify Expert
9 0 3

What if we need to calculate or evaluate multiple values as we need to use the resulting values to modify parts of our theme's liquid? How are we supposed to achieve this with render? We're doing that a lot with include right now.

2 Likes
Shopify Staff
Shopify Staff
9 1 18

You can use the {% capture %} tag to capture the output of the {% render %} and use it in the parent template. In cases where you have multiple resulting values, we recommend either splitting your snippet into multiple snippets, or inlining the code.

 

We understand this is a compromise and that {% render %} has some limitations compared to {% include %}, but we think the benefits around performance and code simplicity are worth it.

1 Like
Highlighted
Shopify Expert
9 0 3

Thanks for the information, @ThibautC. Yes, using capture was also our initial thought, alongside that it wouldn't work for multiple variables as you mentioned.

 

Is there an internal plan or timeframe when the deprecated include will be taken out completely? Do we need to update all out customer themes at some point?

0 Likes
Shopify Staff
Shopify Staff
9 1 18

While {% include %} is deprecated, it will not be removed from the platform, as we don't break backward compatibility in the Liquid/Theme API. However, as part of the new Online Store design experience we are introducing three new types of section files where the {% include %} tag will not be supported.

2 Likes
Shopify Expert
9 0 3

I see, thanks for the clarification.

0 Likes