You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by tdoughty <ti...@gmail.com> on 2012/06/08 08:21:07 UTC

Is it possible to have velocity ignore certain characters?

I'm just starting with Velocity at my internship, but I couldn't find the
answer to this. Is it possible to have Velocity ignore certain characters?
Velocity is giving an error when it encounters a '[' in the html file. I
will post the exact error tomorrow when I have access to my work computer.
The html file looks like:


...

...${variable[encoding=html]}...

...


It gives the error upon reading the opening bracket for encoding=html.
That's the only character that's giving me a problem. I have broken it up
into:


...

#set{$D = '$'}

#set{$VARIABLE = '{variable[encoding=html]}'}

${D}${VARIABLE}

...


This works fine, but there's about a hundred different locations that a
variation of this code is listed in the files and I'm hoping there's an
easier way to manage it. Can you just list certain characters to ignore in
the template, or some variation of this? Thank you!
-- 
View this message in context: http://old.nabble.com/Is-it-possible-to-have-velocity-ignore-certain-characters--tp33979774p33979774.html
Sent from the Velocity - User mailing list archive at Nabble.com.

Re: Is it possible to have velocity ignore certain characters?

Posted by tdoughty <ti...@gmail.com>.
Thank you for the information.

Nathan Bubna wrote:
> 
> No, the parser is JavaCC-generated and not dynamically modifiable.  If
> you are using a lot of syntax that is like VTL, but is not actually
> VTL (like your example), either use literals to avoid the syntax
> conflicts
> 
> http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html#stringliterals
> 
> or consider a different template engine that has a non-conflicting
> syntax, like Freemarker or StringTemplate.  Any time you choose a
> template engine, syntax conflicts should be one of your top concerns.
> 
-- 
View this message in context: http://old.nabble.com/Is-it-possible-to-have-velocity-ignore-certain-characters--tp33979774p33986691.html
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Is it possible to have velocity ignore certain characters?

Posted by Nathan Bubna <nb...@gmail.com>.
No, the parser is JavaCC-generated and not dynamically modifiable.  If
you are using a lot of syntax that is like VTL, but is not actually
VTL (like your example), either use literals to avoid the syntax
conflicts

http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html#stringliterals

or consider a different template engine that has a non-conflicting
syntax, like Freemarker or StringTemplate.  Any time you choose a
template engine, syntax conflicts should be one of your top concerns.

On Thu, Jun 7, 2012 at 11:21 PM, tdoughty
<ti...@gmail.com> wrote:
>
> I'm just starting with Velocity at my internship, but I couldn't find the
> answer to this. Is it possible to have Velocity ignore certain characters?
> Velocity is giving an error when it encounters a '[' in the html file. I
> will post the exact error tomorrow when I have access to my work computer.
> The html file looks like:
>
>
> ...
>
> ...${variable[encoding=html]}...
>
> ...
>
>
> It gives the error upon reading the opening bracket for encoding=html.
> That's the only character that's giving me a problem. I have broken it up
> into:
>
>
> ...
>
> #set{$D = '$'}
>
> #set{$VARIABLE = '{variable[encoding=html]}'}
>
> ${D}${VARIABLE}
>
> ...
>
>
> This works fine, but there's about a hundred different locations that a
> variation of this code is listed in the files and I'm hoping there's an
> easier way to manage it. Can you just list certain characters to ignore in
> the template, or some variation of this? Thank you!
> --
> View this message in context: http://old.nabble.com/Is-it-possible-to-have-velocity-ignore-certain-characters--tp33979774p33979774.html
> Sent from the Velocity - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org