We have added interpolation for string literals. It may offend some of
you purists, so consider it a proposal. Yes, you can turn it off. Here
is how it works :
You can stuff anything you want into a string literal and if
stringliterals.interpolate = true (the default) it will interpolate.
There. Shortest announcement yet.
This is pretty much the most scary, powerful feature we have added,
well, since Velocimacros. Its scary at first blush, but if you control
the jerking-knees and think for a sec, it isn't so bad. You really
can't hurt yourself with it, as all that you can do is parse valid
VTL. There is a small performance penalty, but that will go away after
we optimize it.
Best shown with examples :
1) Simple string interpolation:
#set $one = 1
#set $two = 2
#set $three = 3
#set $out1 = "${one}${two}${three}"
#set $out2 = "$one $two $three"
$out1
$out2
output :
123
1 2 3
2) How about a directive? Sure. We're wacky!
#set $foo = "test.txt"
#set $out = "#include( $foo )"
$out
output :
I am the contents of test.txt.
3) For our next trick, lets interpolate a.... VelociMacro!
#macro( interpfoo )
Hi, I'm a VM!
#end
#set $ivm = "#interpfoo()"
$ivm
output :
Hi, I'm a VM!
4) And now, for something completely different :
#set $code = "#if(false) True #else False #end"
$code
output :
False
or
#set $arr = ["a","b","c"]
#set $foo = "#foreach($a in $arr) >$a< #end"
$foo
output
>a< >b< >c<
Test bed example is interpolate.vm, and it can be turned off with the
stringliteral.interpolate property.
Enjoy. Comments and questions welcome as always.
geir
--
Geir Magnusson Jr. [EMAIL PROTECTED]
Dakota tribal wisdom: "when you discover you are riding a dead horse,
the best strategy is to dismount."