Expected close_square but found pipe

I try to custom the tex with image block and write a for loop below. But it can’t be saved due to the error: Liquid syntax error (line 195): Expected close_square but found pipe in “{{block.settings[“image_” | append: i] }}”

{% for i in (1..5) %}
{%- assign image = block.settings[“image_” | append: i] -%}
{%- assign image_position = block.settings[“image_position_” | append: i] -%}
{%- assign content = block.settings[“content_” | append: i] -%}

{%- if image != blank -%}

xxxxxxxx
{%- endif -%} {% endfor %}

Can anybody please help on this issue? Thanks

Rather than trying to append the index of the for loop within the square braces, I would seperate them out first by assigning an index variable by itself, then using that variable within your square braces.

{% for i in (1..5) %}

{%- assign image_key = “image_” | append: i -%}

{%- assign image_position_key = “image_position_” | append: i -%}

{%- assign content_key = “content_” | append: i -%}

{%- assign image = block.settings[image_key] -%}

{%- assign image_position = block.settings[image_position_key] -%}

{%- assign content = block.settings[content_key] -%}

{%- if image != blank -%}

xxxxxxxx

{%- endif -%}

{% endfor %}

It looks like a syntax error and you’re trying to assign the key within the square braces which isn’t allowed in Liquid.

Hope this helps. If it works, please accept the solution :slightly_smiling_face: