{render} Tag sending Block Object with "with"

Solved
Highlighted

Hi,

I'm trying not to use the deprecated function include, but I cannot get my current block object in my snippet. The documention shows a product example but when I use

{% for block in section.blocks %}

{% assign b = block %}
{% render 'bh_home_interactive_slider' with b %}

{% endfor %}

It will not send the block. I'm rendering in a section theme file, in the block loop -- so I'm trying to sent just the current block.

Any ideas?

 

 

Not every thing is #000000 and #ffffff
0 Likes
Highlighted
Shopify Partner
49 8 12

This is an accepted solution.

Hi @KLGeiger,

Have you tried rendering your snippet directly through a loop? 

{% assign blocks = section.blocks %}

{% render 'bh_home_interactive_slider' for blocks as block %}

Creative director / Partner @ MALVI
0 Likes
Highlighted

Thanks that helps, and got me to a solution. It feels inefficient to have to loop again through blocks and have the snippet qualify when it should be rendered - in my case I only want the snippet rendered when a block. In this scenario, doesn't make sense to me to deprecate include, seems they have different uses. But anyway, thanks!!

Not every thing is #000000 and #ffffff
1 Like
Highlighted
Shopify Partner
49 8 12

Glad I could help! Take care.

Creative director / Partner @ MALVI
0 Likes