Aaah, I get it. That's a serious performance hit but at least it'll get
me up and running so I can make milestone... a good tip. Thank you.
Then later I'll just go back and replace $ and # with \ or whatever the
escape is, so things are fast again.
So what's the history behind the broken escape mechanism? It's not
really an escape mechanism if it can't escape itself, after all. I mean
the problem is, \$foo should always always always output $foo. Because
there is no way of knowing at template time what's in the context and so
there's no way of knowing if random backslashes are going to creep up.
Yeah, I do have a problem with this-- the template "language" I'm
converting from is actually a mish-mash of various post-processing
operations and SSIs, it's a real mess. And unfortunately for me, $ to
end of line marks a 'literal zone'-- where the actual content resides
So pretty much any word that can follow a dollar sign, does! Backslash
is, as usual, used for character escape sequences, and \$ isn't
anything, so luckily it gets ignored. But having random \'s in the code
blocks understandably throws a wrench into things...
So for now ${D} will escape $, and if ${D} ever does appear it will be
${D}{D} which will still work. Good tip, good tip. Thanks,
--jason
Christoph Reck wrote:
Hi Jason,
Velocity was originaly designed such that if you parse a template
with 'schmoo' will output exactly a copy of the input. Any $reference
encountered, which is not in the context should be textually copied
to the output. So I don't understand your problem... Is there one
when you tried parsing your input without escaping?
OTOH, escaping with a backslash \$ only works partially in velocity.
You may call it a "broken" feature.
Use velocity's form of poor man's escaping, which will always work:
#set ($D = '$' )
#set( $H = '#' )
${D}sys.thing($H$H) just a test
will then properly output:
$sys.thing(##) just a test
:) Christoph Reck
Jason Pettiss wrote:
I'm going insane here, maybe someone familiar with the parsing of
velocity templates can help out. I have a document which is all
'schmoo'-- it's not a velocity template... yet. I need to make sure
this document, when parsed by velocity, comes out exactly like it
is-- so that all schmoo is schmoo. But I'm having a hell of a time
doing this.
I figured that it would be a simple matter of escaping every
backslash in the document with another backslash, and then escaping
every $ and # with a backslash. But this doubles the backslashes and
does random stuff with the dollar signs (the directives, at least,
all have their wings clipped).
In particular I notice that \$foo is not guaranteed to come out as
$foo like I would expect. After all what good is an escape sequence
if it doesn't actually escape out of the parsing behavior! But I
find that depending on whether 'foo' happens to be set or not, \$foo
will either come out $foo or \$foo. This extra backslash is totally
uncalled for-- I have no way to escape it, and I have no way of
knowing whether it will appear or not since I don't actually care to
know what's in the document I'm handling. I mean, maybe it was
legitimately talking about the cost of foo, or something.
For those curious, I'm actually converting a gigantic content
repository from an ancient templating language into Velocity. It
involves taking a document, escaping everything that Velocity might
think is Velocity because it's just schmoo, and then sprinkling
Velocity directives and variables all over the document (this IS
Velocity). How do I tell Velocity to piss off without having
backslashes randomly appear all over the place, and without actually
having to know if the schmoo in question has 'conflicts' with the
context variables that are set?
Thank you for any thoughts,
jason pettiss
Catalis, Inc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]