Multiple If's Else if's

I am trying to work out how to create a nested IF statement.
{% If == ‘A’%}
Case A
{% else if == ‘B’ %} -> This is the part that doesn’t work
Case B
{% else %}
Case C
{% endif %}

Is this possible with the if formula or do I need an alternative one?


Hi @faybordbar,

Welcome to the Silverfin community! Hopefully you will find a lot of useful information here and on our developer website:

As for your question, when you create an if statement (or any other control flow statement, there are a few thing to bare in mind:

  1. No capitalisation should be used in keywords (in this case no capitalisation of if);

  2. There is a keyword elsif which is one word (used for your second statement);

  3. Please do not use reserved words in naming your variables, functions, labels (for example text since it is a variable type in liquid). You can call it some_text or text_1, etc. Useful link: Naming variables

  4. nested if statement is an if statement inside which there is another if statement (an example provided below, usually different logic is checked in each statement):

    {% if == ‘A’ %}
    Case A
    {% elsif == ‘B’ %}
    Case B
    {% else %}
    {% if != blank %}
    Not blank
    {% else %}
    {% endif %}
    {% endif %}

Let us know if you need any more help or if you have any more questions. And good luck in your coding journey!