You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Will Glass-Husain <wg...@gmail.com> on 2011/06/01 07:26:36 UTC
syntax change in velocity 1.7
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
Re: syntax change in velocity 1.7
Posted by Will Glass-Husain <wg...@gmail.com>.
Thanks, Claude,
That's probably what I'll end up doing. Either one time or possibly do it
dynamically in a custom resource loader.
(The problem is these files are all spread out in different accounts with
different authors and versioning).
WILL
On Wed, Jun 1, 2011 at 1:11 AM, Claude Brisson <cl...@renegat.net> wrote:
> You can alter your templates to match the new syntax, something like:
>
> find . -name "*.vtl" | xargs sed -ri -e
> "s/\\\$([a-z.\(\)]+)(\[[^\]+])/$\{\1\}\2/g"
>
> so that every reference which is followed by square brackets will be
> enclosed in curly brackets.
>
>
> Claude
>
>
> On 2011-06-01 09:44, Sergey Maslov wrote:
>
>> No ideas...
>>
>> On Wed, Jun 1, 2011 at 9:26 AM, Will Glass-Husain
>> <wg...@gmail.com> 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: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
Re: syntax change in velocity 1.7
Posted by Claude Brisson <cl...@renegat.net>.
You can alter your templates to match the new syntax, something like:
find . -name "*.vtl" | xargs sed -ri -e
"s/\\\$([a-z.\(\)]+)(\[[^\]+])/$\{\1\}\2/g"
so that every reference which is followed by square brackets will be
enclosed in curly brackets.
Claude
On 2011-06-01 09:44, Sergey Maslov wrote:
> No ideas...
>
> On Wed, Jun 1, 2011 at 9:26 AM, Will Glass-Husain
> <wg...@gmail.com> 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: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: syntax change in velocity 1.7
Posted by Sergey Maslov <th...@gmail.com>.
No ideas...
On Wed, Jun 1, 2011 at 9:26 AM, Will Glass-Husain
<wg...@gmail.com> 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: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: syntax change in velocity 1.7
Posted by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com>.
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: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org