For those of you that ignore commit diff-gibberish, last night I
checked in changes to the parser and the AST code to support
single-quote string literals ( '$foo' ) in VTL. Unlike their
double-quote siblings ( "$foo" ) they won't be interpolated. Think
'Perl' here. This was brought up and discussed a while back so I don't
think anyone will be upset, surprised or diappointed, but if so, say so.
To review :
1) There is a property stringliterals.interpolate, default true, that
controls interpolation of string literals.
2) When true (the default), any string literal contained in double-quote
characters ( " ) will be parsed and rendered. This can be as simple as
doing string concatenation :
#set( $directoryRoot = "www" )
#set( $templateName = "index.vm" )
#set( $template = "$directoryRoot/$templateName" )
$template - renders as -> www/index.vm
or invoking directives and Velocimacros :
#set( $templateName = "index.vm" )
#set( $template = "#if($root) #makedirectorypath( $root $template )
#else default/$templateName #end" )
and with $root not defined in the context :
$template - renders as -> default/index.vm
where #makedirectorypath() is some Velocimacro.
See interpolation.vm in test/templates for more [wacky] examples.
3) When the string literal is bounded by single-quote characters ( ' )
no interpolation occurs.
#set( $blargh = '$foo' )
$blargh - renders -> $foo
As always, comments, discussion, etc...
geir
P.S. Anyone think that the situational pun in the Subject was funny? :)
--
Geir Magnusson Jr. [EMAIL PROTECTED]
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity