Unfortunately, there is no introspection in Velocity.
One complicated idea would be to "meta parse your template".
The idea would be to use a kind of Velocity introspection on all your templates.
Each time this introspection encounter a variable, like ${a} or a, you replace
it with a "meta template" that would content ${variableName} and would produce
${a}.
So, finally, it would do the job for you.
The only thing you need is that Velocity introspection but as far as I remember
it doesn't exist.
On 1 juin 2011, at 07:26, Will Glass-Husain wrote:
> Hi,
>
> I just did a test upgrade of a site from Velocity 1.6.2 to Velocity 1.7. A
> number of my templates started to fail because they included square
> brackets. (Ironically, we discovered this soon after I finished describing
> to my coworkers the project's obsessive stance on backwards compatibility).
> My pages often reference mathematical values, and the bracket is a common
> part of the text.
>
> This used to work
>
> #for($var in $varList)
> $abc[sub1]
> #end
>
> which would print something like
> Sales[sub1]
> Revenue[sub1]
> Cost[sub1]
> etc
>
> Now it gives a parse error.
>
> I see that ${abc}[sub1] keeps the old behavior. However, searching our site
> there have 40+ pages with many of these now illegal references. (Many by
> other authors).
>
> Any suggestions as to how I can keep the backwards compatible parsing
> behavior?
>
> I'll dig into the Velocity code, see if I can think of anything helpful.
> But just wanted to check if others had ideas.
>
> WILL
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]