I already posted a similar question a week ago on How to use 'for' loop in velocity template?.
So...basically I can't use 'for' loop in a velocity template.
Let's say I have a variable that holds integer 4. I want to display something four times using that variable. How do I do it in a velocity template?
3.2 Create a Velocity Template Writer Initialize the Velocity engine. Read the template. Put the data model in a context object. Merge the template with context data and render the view.
Velocity is a server-side template language used by Confluence to render page content. Velocity allows Java objects to be called alongside standard HTML. If you are are writing a user macro or developing a plugin you may need to modify Velocity content.
Approach 1: The obvious approach: Run and check. Run Velocity against the template to be checked. Look at the output and see if it is what you desired. This must be the most primitive testing approach, but most people nowadays are too lazy and want this done by the computer.
Try to do it like this:
#set($start = 0) #set($end = 4) #set($range = [$start..$end]) #foreach($i in $range) doSomething #end
The code has not been tested, but it should work like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With