In Qute, is it possible to accumulate variables using a for loop before outputting the result? #52213
Replies: 2 comments 2 replies
-
|
\CC @mkouba |
Beta Was this translation helpful? Give feedback.
-
Yes, this will not work and it's expected because the local variables are not available outside the Also note that Like I said in https://github.com/quarkusio/quarkus/discussaons/51053#discussioncomment-15095982 I would not recommend to do calculations in Qute templates. Qute was originally designed to contain minimal logic and computations should be performed in the Java code. We could try to find a workaround though... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In my work, there's a template configuration that needs to perform an accumulation calculation on a variable, then add the result and output it. However, it doesn't seem to be working. Below is a demo I've written so far.
{#let sum = 0} {#for i in items} {#set sum = sum + i} {/for} {sum} {/let}How can I implement this logical calculation?
Beta Was this translation helpful? Give feedback.
All reactions