Programmatically include snippet on template page

Highlighted
Tourist
5 0 1

Hey,

 

I want to include a snippet file inside a specific template page (or theme.liquid layout if required) programmatically through my app.

Purpose - so that I can access the global variables created by the snippet containing liquid by script tags.

 

I want to add the below statement without asking merchants to manually put it in the file.

{% include 'snippet name' %}


I am adding the snippet file through the Asset API and the snippet is inserted properly.

PUT /admin/api/#{api_version}/themes/#{theme_id}/assets.json

 

Will using the same API again for updating a template file completely change the original file or just add the 'include' statement at the end? How should I go about doing this?

0 Likes
Tourist
5 0 1

Can anyone advice here on how to achieve this?

0 Likes