Home > Back-end >  Liquid syntax error (line 4): Expected end_of_string but found pipe in "forloop.index0 | modulo
Liquid syntax error (line 4): Expected end_of_string but found pipe in "forloop.index0 | modulo

Time:10-05

This error is because of the code written with incorrect syntax below. Could you please help fix the syntax error at those two lines in it?

{% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
{% if forloop.last || forloop.index | modulo: 3 == 0 %}


<div class="impact-items">
 {% for block in section.blocks %}
  {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
  <div class="impact-content col-xs-12 col-md-4">
   <div class="impact-icon"><img src="{{block.settings.impact_icon | img_url: 'master' }}"></div>
   <div>
    <div class="impact-number">{{block.settings.impact_number}}</div>
    <div class="impact-text">{{block.settings.impact_text}}</div>
   </div>
  </div>
  {% if forloop.last || forloop.index | modulo: 3 == 0 %}
   </div>
  {% endif %}
 {% endfor %}
 <div class="row">
  <div class="mt2x btn center-xs col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href='https://packedwithpurpose.gifts/our-impact/impact-report-2020/'><button>Learn More About our Impact</button></a></div>
 </div> 
</div>

CodePudding user response:

You're missing closing If statement at the end. {% endif%}

Here is the complete code with no error -

{% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
{% if forloop.last || forloop.index | modulo: 3 == 0 %}
<div class="impact-items">
 {% for block in section.blocks %}
  {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
  <div class="impact-content col-xs-12 col-md-4">
   <div class="impact-icon"><img src="{{block.settings.impact_icon | img_url: 'master' }}"></div>
   <div>
    <div class="impact-number">{{block.settings.impact_number}}</div>
    <div class="impact-text">{{block.settings.impact_text}}</div>
   </div>
  </div>
  {% if forloop.last || forloop.index | modulo: 3 == 0 %}
   </div>
  {% endif %}
 {% endfor %}
 <div class="row">
  <div class="mt2x btn center-xs col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href='https://packedwithpurpose.gifts/our-impact/impact-report-2020/'><button>Learn More About our Impact</button></a></div>
 </div> 
</div>
{% endif %}

CodePudding user response:

    {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
    {% if forloop.last || forloop.index | modulo: 3 == 0 %}
    <div class="impact-items">
     {% for block in section.blocks %}
    {% modulo = forloop.index0 | modulo: 3 %}
      {% if modulo == 0 %}<div class="row">{% endif %}
      <div class="impact-content col-xs-12 col-md-4">
       <div class="impact-icon"><img src="{{block.settings.impact_icon | img_url: 'master' }}"></div>
       <div>
        <div class="impact-number">{{block.settings.impact_number}}</div>
        <div class="impact-text">{{block.settings.impact_text}}</div>
       </div>
      </div>
      {% if forloop.last || forloop.index | modulo: 3 == 0 %}
       </div>
      {% endif %}
     {% endfor %}
     <div class="row">
      <div class="mt2x btn center-xs col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href='https://packedwithpurpose.gifts/our-impact/impact-report-2020/'><button>Learn More About our Impact</button></a></div>
     </div> 
    </div>

{% endif %}
  • Related