How do a loop n.times in Liquid templating using an existing for loop

后端 未结 2 984
醉梦人生
醉梦人生 2021-01-02 10:03

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

My current loop is: for video in site.posts my goal is to run this loop 2 times. There are

2条回答
  •  心在旅途
    2021-01-02 10:33

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

    {% for num in (1..n) %}
    

    In some instances of Shopify Liquid, it may also work to use

    {% for num in (1...n) %}
    

提交回复
热议问题