-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No boolean operators for conditions #311
Comments
It shouldn't be too hard to add that in, the relevant code is here Line 85 in a535a5c
Any chance you'd be up to do a PR for this? :) |
Yeah guess not. In my case I also need nested conditions, like:
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. |
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..
The text was updated successfully, but these errors were encountered: