Logical operators
Closed this issue · 1 comments
Igor-Palaguta commented
Thanks for Stencil!
It will be great if it can support logical operators like &&, ||, !
Sure it can be done with if
combinations, but it looks not so pretty
e.g.
Instead of this:
{%if listA || listB %}
enum All {
{% for a in listA %}
case {{ a }}
{% endfor %}
{% for b in listB %}
case {{ b }}
{% endfor %}
}
{% endif %}
We have to write this:
{% ifnot listA %}
{% ifnot listB %}
{# do nothing #}
{% else %}
enum All {
{% endif %}
{% else %}
enum All {
{% endif %}
{% for a in listA %}
case {{ a }}
{% endfor %}
{% for b in listB %}
case {{ b }}
{% endfor %}
{% ifnot listA %}
{% ifnot listB %}
{# do nothing #}
{% else %}
}
{% endif %}
{% else %}
}
{% endif %}
kylef commented
This has now been implemented in master, you can find documentation for this feature at https://stencil.rigidapp.com/builtins.html#if.