twig switch case

Solutions on MaxInterview for twig switch case by the best coders in the world

showing results for - "twig switch case"
Eduardo
29 Jun 2016
1// There is no switch statement... use if - elseif instead
2{% if condition %}
3...
4{% elseif condition2 %}
5...
6{% else %}
7...
8{% endif %}
9
10/*
11Some sites like 
12	https://www.branchcms.com/learn/docs/developer/twig/tags/item/switch
13define switch as follows, but it doesn't render...
14
15{% set value = 'value2' %}
16{% switch value %}
17    {% case 'value1' %}
18        <p>value is "value1"</p>
19    {% case 'value2' %}
20        <p>value is "value2"</p>
21    {% case 'value3' %}
22    {% case 'value4' %}
23        <p>value is "value3" or "value4"</p>
24    {% default %}
25        <p>value is something else</p>
26{% endswitch %}
27*/