Integrating snippet into {% raw %} tag.

Highlighted
New Member
1 0 0

Hi, I have ajax cart on my store.

As many themes does, ajax cart template uses {%raw%}{%endraw} code. I need to integrate a snippet provided by an app inside the code tag.

I tried to split the whole code so it looks like this.

{%raw%} ... {% endraw %} {%render 'snippet_name', line_item:item %} {%raw%} ... {% endraw %}

The problem is the 'item' parameter. Since for loop is inside {%raw%} tag, I am not sure how to get current looping item to use as the snippet parameter.

Look forward to your help.

Regards.

0 Likes
Highlighted
Excursionist
35 8 15

Gday!

I am a little confused with your usage of the raw tag. Are you using it within handlebars.js to escape Liquid?

Wrapping just the handlebar could be a solution, as the Liquid loop will run server-side then the {{ handlebar_prop }} can be dealt with client-side. Something like:

{% for product in collection.products %}
   <div>{% raw %} {{ handlebar_prop }} {% endraw %} </div>
{% endfor %}


If you provide a bit of context and some code snippets I could look into it a bit further 

Let me know how you go!

 

If comment was helpful, hit Like!
Solved your issue? Set Accept as Solution!
Need a quote? Contact glenn@plankcreative.com.au to get in touch!
0 Likes
Highlighted
Astronaut
1082 178 213

Hey @pooneh 

Did you try assigning the "item" to an external variable?

{% assign my_item = item %}
 {%raw%} ... {% endraw %} {%render 'snippet_name', line_item:my_item %} {%raw%} ... {% endraw %}

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes