No boolean operators for conditions
I know there is "all" and "any" in conditions, but there doesn't seem to be an "and" (or "or") operator for instance?
Like: {% if condition-a and condition-b %} (or perhaps "if and conditon-a condition-b")
Right now I need to nest two if-tags, which is not so nice..
It shouldn't be too hard to add that in, the relevant code is here https://github.com/yogthos/Selmer/blob/a535a5c55e078288e5da58b6be5e1ae1b744b3c1/src/selmer/tags.clj#L85
Any chance you'd be up to do a PR for this? :)
Yeah guess not. In my case I also need nested conditions, like:
{% if (not condition-a) and condition-b %}
is there support for nested conditions right now? It does not seem like it. It's basically just about a general expression evaluator.
Seems like even the Django template language supports this?
https://www.geeksforgeeks.org/boolean-operators-django-template-tags/
Nested conditions would be a bit trickier as it'd need a bit of a redesign as I recall. The original idea was to provide fairly minimal support for logic as you can always do fancier transforms in Clojure before passing the data to Selmer.
All right. Well just one level deep conditions (but ideally including support for not operator in subexpressions) would perhaps be a good compromise (and be on par with Django's language). But unless I get quite bored in the near future I have to admit this is not a high priority for me, and my current project is a one man show where I much prefer Hiccup anyway. And as you say there is always the possibility to do more logic in Clojure behind the scenes.
Yeah, I find Hiccup is generally preferable as well. The main use for Selmer is to provide something familiar for people coming from other languages. It also can be useful outside HTML templating since it's agnostic regarding the content it processes.