Like a loop in Liquid tempating patterns using an existing loop

In ruby ​​I can do n.times, is it possible to do this in Liquid markup?

My current loop: for the video in site.posts, my goal is to run this loop 2 times. There are currently 4 objects to be called through the loop, but I want 8. Hope this is clear!

+4
source share
2 answers

You should be able to use a for loop with a range ( n is the number of iterations):

 {% for num in (1...n) %} 
+9
source

If you are like me, you want to have a dynamic number that is not based on the length of the collection or the built-in var, which you can use as values ​​and default values ​​during capture to work wonders.

 {% capture count %}{{include.count|default:16}}{% endcapture %} {% for num in (1...count) %} {{num}} {% endfor %} 
0
source

Source: https://habr.com/ru/post/1442644/


All Articles