Code template Apache Velocity - iterating over an array
Hi,
I hope you are well.
I was wondering how to access simple operations like iterations from within a code template.
I am trying to create a template for typescript testing using the apache velocity documentation.
// tslint:disable:no-expression-statement
import { test } from 'ava';
import {} from './${NAME}';
#foreach( $export in $exports )
test('$export', t => {
t.is($export(''), true);
t.is($export(''), false);
});
#end
Thanks for any pointers you might offer.
Please sign in to leave a comment.
It can look as follows:
#set($exports = $input.split(" "))
#set(${export} = "")
// tslint:disable:no-expression-statement
import { test } from 'ava';
import {} from './${NAME}';
#foreach( ${export} in $exports )
test('${export}', t => {
t.is(${export}(''), true);
t.is(${export}(''), false);
});
#end
Enter the input values separated by space:
it will generate