jeff wrote:
> 
> As I understand it, escaping the $ char is context sensitive.  i.e.
> \$foo will render as $foo if $foo is defined but as \$foo if foo is
> undefined.  To me this seems very unfortunate.  Suppose I want to create
> a template fragment for use in many different templates which needs to
> render a literal $foo.  This is impossible since I can never be sure
> whether or not foo will be defined and so I won't know whether to put
> \$foo or $foo in the fragment.
> 
> Now this is not a huge problem, but it seems like an unnecessary one.
> Why were escapes designed to work this way?

As I recall, the main point was that we don't want to have people modify
their input content unnecessarily just because we decided that '$' is
the start of our reference.  It's a trade off, but since vel is general
purpose, we don't assume that each template is hand crafted by a
designer - you could take random stuff, such as a news feed, add some
VTL somewhere (such as search for stock tickers and put a link to your
quote page...)  and run through the template engine, and it should do no
harm to the material you didn't touch.

Could you use #if() ? #if($foo) -> false if $foo not in the context.

Or

#set($blarg123 = '$foo' )
 $blarg123

should work too...  Of course, you then have to worry about 'blarg123'
in your context...

I understand your problem, but I hope you can see some of the
reasoning.  Any suggestions?

geir

-- 
Geir Magnusson Jr.                               [EMAIL PROTECTED]
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

Reply via email to