-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Qute: add some more built-in string extensions #46258
Conversation
mkouba
commented
Feb 13, 2025
- str:concat, str:join, str:builder, str:eval
🙈 The PR is closed and the preview is expired. |
d99e411
to
3ff0109
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thansk!
- str:concat, str:join, str:builder, str:eval - also slightly optimize EvalSectionHelper for the cases where a template literal with no params is used
3ff0109
to
aae8420
Compare
Status for workflow
|
This comment has been minimized.
This comment has been minimized.
Status for workflow
|
I think that eval is implemented but not used in StringTemplateExtensions.java class. Sorry for commenting on a closed one :) |
Indeed, it has to be implemented as a But from user POV it's kind of a "string extension" ;-). |
Is this a bug? I'm confused. When I use |
That's weird. This namespace resolver was also added in this PR. Could you share a sample of your app that would demonstrate the problem? What does the stack trace look like? |
This is the error that I get. Check the reproducer here Caused by: io.quarkus.qute.TemplateException: Found incorrect expressions (1):
[1] root.html:19:1 - {str:eval('Hello')}: No matching namespace [str] extension method found
at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:272)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
at io.quarkus.builder.BuildContext.run(BuildContext.java:255)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at java.base/java.lang.Thread.run(Thread.java:1583)
at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Suppressed: io.quarkus.qute.TemplateException: root.html:19:1 - {str:eval('Hello')}: No matching namespace [str] extension method found
at io.quarkus.qute.TemplateException$Builder.build(TemplateException.java:169)
at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:237)
... 10 more |
Ok, so it's the build-time validation failure. Maybe we don't have a test for this. I'll take a look. Thanks for the report! |
@gbourant You're absolutely right, we do fail the build if there's at least one template extension method for a namespace ( A workaround exists, just add the following dummy template extension method - it will be never used but tricks the validation: @TemplateExtension(namespace = "str", matchName = "eval", priority = Integer.MIN_VALUE)
static String dummy(String template) {
throw new UnsupportedOperationException();
} |
- when a matching template extension method exists - this is a follow-up of quarkusio#46258