Welcome to the Liquify Community

Updated 7 days ago

How do I wrap a for statement in an assign statement?

Would I need another div or would ':inside' work? I am going for

{% assign limit = 3 %}
{% assign counter = 0 %}
{% for article in blogs['Release'].articles %}
{% if counter < limit %}
{% if article.image %}
J
L
2 comments
Hey Levi, you could do something like this:
<div li-tag="assign limit = 3"></div>
<div li-tag="assign counter = 0"></div>

<div li-for:inside="article in blogs['Release'].articles">
<div li-if="counter < limit and article.image">
Content
</div>
</div>

The li-tag divs will be removed during the conversion, so at the end you will only have the HTML content you actually need :)
Oh this is great! Thank you!
Add a reply
Sign up and join the conversation on Discord