Velocity template - foreach loop

Answered

Hi,

I'm trying to modify the default PHP constructor template to have a multiline constructor instead of a single line one.

I came up with this code which only displays one parameter and doesn't display the body of the constructor... It seems to stop at the #end instruction

Can somebody help ?

/**
* ${CLASS_NAME} constructor.
${PARAM_DOC}
${THROWS_DOC}
*/
public function __construct(
#foreach ($param in $PARAM_LIST.split(","))
$param
#end
) {
${BODY}
}
0
2 comments

Please try 

/**
* ${CLASS_NAME} constructor.
${PARAM_DOC}
${THROWS_DOC}
*/
public function __construct(
#foreach ($param in $PARAM_LIST.split(","))
$param #if($foreach.hasNext), #end
#end
) {
${BODY}
}
0

Works great! Thanks!

1

Please sign in to leave a comment.