Skip to content Skip to sidebar Skip to footer

NVelocity Advance Lopping Syntax

Currently I am doing a project which involve Nvelocity template, however, I need use advance foreach, I could find the reference, just I could not figure out how does it works,refe

Solution 1:

The NVelocity special foreach looping directives are just nested sections inside the foreach directive, which you define bits of the template. Following is an example of the basic structure for putting a comma between each item:

#foreach($i in [1..5])
#between
,
#each
$i
#end

Because the nested directives cannot contain anything else on the same line they and because of the newline that is included at the end they can be a bit of a pain if you care about extra whitespace appearing, so if you want the output to look exactly like "1,2,3,4,5" without any whitespace you'll need to remove some of the newlines between things like follows:

#foreach($i in [1..5])#between
,#each
${i}#end

Post a Comment for "NVelocity Advance Lopping Syntax"