Welcome to the Liquify Community

Updated 3 weeks ago

First questions

Hi! I'm just starting out reading the documentation and looking at the starter template. I've got a few questions:

Can I inject liquid like this inside Webflow? I want to use this inside a for loop.

{%- for option1_name in variants_option1_arr %}
{%- case option.position %}
{%- when 1 %}
{%- if variants_option1_arr[forloop.index0] == value and variants_available_arr[forloop.index0] %}
{%- assign option_disabled = false %}
{%- endif %}
{%- when 2 %}
{%- if option1_name == product.selected_or_first_available_variant.option1 and variants_option2_arr[forloop.index0] == value and variants_available_arr[forloop.index0] %}
{%- assign option_disabled = false %}
{%- endif %}
{%- when 3 %}
{%- if option1_name == product.selected_or_first_available_variant.option1 and variants_option2_arr[forloop.index0] == product.selected_or_first_available_variant.option2 and variants_option3_arr[forloop.index0] == value and variants_available_arr[forloop.index0] %}
{%- assign option_disabled = false %}
{%- endif %}
{%- endcase %}
{%- endfor %}

It is possible to add an attribute inside a condition? like this:

<input type="radio" {% if option.selected_value == value %}checked{% endif %}</input>

These were my questions for now πŸ™‚
j
H
10 comments
Hi @Hendrik,
for the first case you can use <div li-tag="for option1_name in variants_option1_arr %}
{%- case option.position %}
{%- when 1 %}
{%- if variants_option1_arr[forloop.index0] == value and variants_available_arr[forloop.index0] %}
{%- assign option_disabled = false %}
{%- endif %}
{%- when 2 %}
{%- if option1_name == product.selected_or_first_available_variant.option1 and variants_option2_arr[forloop.index0] == value and variants_available_arr[forloop.index0] %}
{%- assign option_disabled = false %}
{%- endif %}
{%- when 3 %}
{%- if option1_name == product.selected_or_first_available_variant.option1 and variants_option2_arr[forloop.index0] == product.selected_or_first_available_variant.option2 and variants_option3_arr[forloop.index0] == value and variants_available_arr[forloop.index0] %}
{%- assign option_disabled = false %}
{%- endif %}
{%- endcase %}
{%- endfor"></div>

Like this. li-tag adds {% %} at the end and the beginning
for the second question you can use li-attribute:liquid="{% if option.selected_value == value %}checked{% endif %}"
There you can use liquid freely.
We also have introduced li-liquid attribute on custom embeds. But this has currently some small issues
Great thanks! I'll have a try right away!
Hmm unfortunately webflow adds some spaces to the liquid when exporting 😦
Attachment
Screenshot_2024-10-30_at_13.52.36.png
how have you tried it? Can you send me a screnshot?
I've attatched a screenshot above πŸ™‚
the li-attribute:liquid also removed some spaces which resulted in:
Attachment
Screenshot_2024-10-30_at_13.57.12.png
Hi @Hendrik, have you solved the issue?
Add a reply
Sign up and join the conversation on Discord