-
Notifications
You must be signed in to change notification settings - Fork 51
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
feat: add Quarkus CLI commands #734
Conversation
metacosm
commented
Oct 3, 2023
- chore: initial work on CLI plugin
- wip: first commands layout
- feat: first implementation of API creation command
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.
LGTM
.forEach(path -> { | ||
try { | ||
final var templateAsString = java.nio.file.Files.readString(path); | ||
final var templateInstance = Qute.fmt(templateAsString) |
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.
Like I mentioned, this is not ideal in the sense that the template content is parsed every time the Qute#fmt()
method is called. If you need to render the template multiple times then either use Qute.enableCache()
or Qute.engine().parse(...)
together with Qute.engine().putTemplate()
and Qute.engine().getTemplate()
...
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.
I couldn't get it to work in that context, though… where all the templates are retrieved from the jar and processed the same way. If you have a better way to do, I'll gladly consider it :)
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.
What I'm saying is: if you only render the template once, then Qute.fmt(templateAsString)
is OK. If multiple times, then either use Qute.enableCache()
- this enables cache for Qute.fmt()
by default (templateAsString
will be parsed once); or use something like:
// This should be called once
Engine engine = Qute.engine();
engine.putTemplate("myTemplate", engine.parse(templateAsString));
...
// And then to render a template:
Qute.engine().getTemplate("myTemplate").render();
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.
Ah, I think I was missing the putTemplate
part, I thought that I could call getTemplate
directly and that wasn't working. Thanks! That said, since these things won't probably be run very often, I'm not sure it matters but I might still make the change (it might help when called from the dev console, maybe?). Then again, you could make a point that if it's not going to be called often, caching a template might actually be worse because then you commit memory to something that will only be used infrequently and possibly only once.
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.
Yes, it really depends on the use case 🤷 .
Signed-off-by: Chris Laprun <claprun@redhat.com>