Christoph Reck wrote:
>
> 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?
>
> The rationale was that VM will parse/render anything, only the active
> directives and context variables must be escaped if not intended
> to be used as such.
>
> WORKAROUND:
> Use the poor man's escape. It will allways work!
> #set( $D = '$' )
> ${D}foo has the value of '$!foo'
>
> Hope this helps.
It does. I like this hack best of all.