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
Support complex expressions in Qute #6369
Comments
Neither of these is supported ATM (and it's documented ;-). I personally tend to avoid complex expressions in templates (as it usually leads to more error prone code) and follow the idea of templates with minimal logic. However, the |
FWIW, we also need some expression language support in the Spring Security extension. /cc @geoand It might be worth it to use the same implementation. For the record, Hibernate Validator uses Jakarta EL. |
Yeah I had to do a pretty lame implementation of a small subset of SpEl for the security stuff. |
So I don't want to repeat myself but I really don't think it's a good idea to build template expressions on top of a complex EL by default, of course it could be optional... ;-) |
@mkouba I don't think we want to push you to do what you don't feel right, just wanted to say that there is a common need for this sort of things. |
Complexity surely is in the eye of the beholder, but boolean expressions with && or || are fairly common in template logic to conditionally display contents. I also was missing method calls, in particular equals(), as otherwise string comparisons are impossible. |
I'm not sure an EL makes sense when you've already got a template language: then you have two languages, possibly with overlap, certainly with combinatorial effects... Wouldn't it be better to define one language with a complete grammar and predictable behaviors? |
Well, if included in the template engine, at least let's make the syntax consistent with what we will use for Spring Security where we definitely need an EL. |
From my PoV, if we define the minimum common set of expressions we could reuse everywhere, it would be great. |
It would be a good idea to provide |
Qute is not an EL, it's a template language which also supports expressions. The choice of expression language should be a technical decision, not a political one: it seems possible that Jakarta EL is not going to be the right fit. |
Ok, so Qute is something like Velocity or Freemarker but optimized for quarkus runtime. The I dont know why Jakarta EL is not the right fit for Qute but there will be definitly a need for more advanced expressions in the future because we see it in the use cases of velocity or freemarker or jsf. There is a possibility that Jakarta EL will be used in future for other things in quarkus (for example, if someone provides a jsf-extension). Would something like |
"Method calls" are supported but not available out of the box. You can use
@gunnarmorling FYI ;-) |
That's very similar to what I have in |
Didn't we want to auto-register methods for classes we know are used in the template thanks to typing info? I definitely vote for supporting boolean, math and comparison expressions. |
IMO a strict subset of Unified EL would be good, if we can or don't want to support the full thing. This would reduce friction when coming from or combining Qute and Unified EL in a project, e.g. when using HV. |
That's the plan. But so far we only support "properties" because it's much simpler to implement. |
A related issue was documented in a comment here:
|
FYI we already support a bit more complex expressions in 1.2.0, for example:
|
- relates to quarkusio#6369
- relates to quarkusio#6369
Closing, the original expression |
I'd like to use boolean operators like
&&
and||
. Currently, when using an expression such as{update && todo.completed}
, I'm getting a stacktrace like this (bothupdate
andtodo
are variables in the template context):Interestingly, behavior is different when using an
if
:In this case no exception is raised but it seems the second operand is silently ignored.
The text was updated successfully, but these errors were encountered: