Reputation: 12189
Having:
#set( $maxVersion = 500 )
I'd like to populate list like this:
$myList = ("someString_10" "someString_20" "someString_30" ... "someString_500")
Any chance to populate it dynamically using velocity template only?
I've seen in the official docs, there is a support for the lists as well as for the #foreach
loop. However it doesn't help here, I'd need kind of for/while specifying the condition to end the loop.
Upvotes: 0
Views: 4846
Reputation: 11611
#set ($maxVersions = 500)
#set ($step = 10)
#set ($start = 1)
#set ($count = $maxVersions / $step)
#set ($myList = [])
#foreach ($i in [$start..$count])
#set ($item = $i * $step)
#set ($discard = $myList.add("someString_${item}"))
#end
$myList
Upvotes: 3