Search code examples
swig-template

Write multiple statements in swig expression tag?


i am tring to write multiple line in my swig expression tag but conditions are not evaluting, but if i write all the statements in different tag then it is working. Please find following example :

{% set promo_class = "whatone" %}

{% if (loop.index % 2) == 0 %}

{% set promo_class= promo_class +" mhxxl"; %}

{% endif %}

Following is not working for me, while above one is

{%

set promo_class = "whatone";

if ( loop.index % 2 ) == 0

set promo_class= promo_class +" mhxxl";

endif;

%}

Solution

  • Block statements are not part of the Swig Template language. Nowhere in the documentation does it show that as an example or an available syntax style.