You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2000/12/19 15:54:04 UTC
more escaping fun
Cameron found a few more bugs in the parser regarding escaping, and I
think I fixed them. Historically, I am very muddleheaded when thinking
about escaping (doesn't involve threads or something...), so we should
review what I did :
Since this is stuff for 'specialized' use, I think, in that the users of
this will be 'experts' doing something unusual, like generating Velocity
templates or producing VTL documentation, I am not to upset that it's
not as clean as our regular escaping rules. If someone is, lets talk
about it.
1) The biggie : In a reference-like thing (RLT for short), when you
preceed a '!' with any number of \ characters, that RLT is no longer
considered a reference. Contrast this to \\$ref which will render as
\<ref> if ref in the context, or \\$ref if not. My argument is that
$\\!ref has no VTL meaning at all.
Therefore, no matter what the context holds :
$\!foo renders as $!foo
$\\!foo renders as $\!foo
$\\\!foo renders as $\\!foo
So, only the rightmost \ binds to the !, and unlike escapes preceeding $
and #, they don't start collapsing by twos (like our other escapeing
rules) because :
$\\!foo would be void of meaning if we collapsed the two slashes
together and had none left to escape the !. I know I am explaining this
badly, but just contrast to how it works for $ or # and you will see
what I mean :
\\#if() - renders as -> \
\#if() - renders as -> #if()
\\$ref - renders as > \<ref> or \$ref depending on context
We could bind from the left into pairs as conventional escaping:
$\!foo => $!foo
$\\!foo => $\!foo
$\\\!foo => $\!foo
That's wierder to me. I guess the symmetry is broken because the fact
that a \ is between $ and ! is an 'action' unto itself, whereas in
normal escaping, the \x binding has meaning.
Anyway, lets dicuss if history repeats and I muddled this up.
2) The other :
if foo is in the context and bar isn't :
\$!foo renders as $!foo
\$!bar renders as \$!bar
geir
--
Geir Magnusson Jr. geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity