{render} Tag sending Block Object with "with"

Solved

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
pvoulg
Shopify Partner
171 26 48

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 %}

Panos Voulgaris
Creative director / Partner @ MALVI
Founder @ function( )
0 Likes

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
pvoulg
Shopify Partner
171 26 48

Glad I could help! Take care.

Panos Voulgaris
Creative director / Partner @ MALVI
Founder @ function( )
0 Likes
vanessas
Tourist
4 0 1

May I ask what was the solution you found? I'm having the same issue, only being able to use include to render my snippet as I'm using different cases. 

0 Likes