You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by ma...@nokia.com on 2003/03/24 13:01:33 UTC
Rendering with escapes.
Hello.
I just started using Velocity. The text below is taken from the Velocity User Guide. I didn't understand why \\\$email would render as \\\$email. I tried it and it renders as \\$email. Am I missing something?
Cheers,
Matti Aaltonen
Note that the \ character bind to the $ from the left. The bind-from-left rule causes \\\$email to render as \\$email. Compare these examples to those in which > > $email is not defined.
$email
\$email
\\$email
\\\$email
renders as
$email
\$email
\\$email
\\\$email
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Display all context variables in a template
Posted by Joseph Rosenblum <ro...@corp.earthlink.net>.
I use something like this:
Object [] keys = context.internalGetKeys();
for (int i=0; i< keys.length; i++) {
output.append((String)keys[i] + " -- " +
context.internalGet((String)keys[i]) + "\n");
}
-Joe Rosenblum
On 3/24/03 1:05 PM, "Franck Arnulfo" <fa...@pipoware.com> wrote:
> Hi,
>
> I would like to print all context variables in a template.
> Is there a simple way to do that ?
>
> Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Display all context variables in a template
Posted by Franck Arnulfo <fa...@pipoware.com>.
Hi,
I would like to print all context variables in a template.
Is there a simple way to do that ?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Rendering with escapes.
Posted by Ch...@dlr.de.
Hi,
there seems to be some problems with reference and directive escaping in
velocity. A failsafe way of escaping can be achieved as follows:
#set( $Q = '"' )
#set( $D = '$' )
#set( $P = '#' )
...
You can use the above definitons to write directives to the output:
${P}if( ${D}email )Hello World!${P}end
Not very nice, but 100% predictable - and better than \\\$email :-D
The reason velocity acts like this with the escapes is described
in the documentation. Velocity behaves differently whether the
reference is in the context or not.
Hope this helps,
Christoph
matti.j.aaltonen@nokia.com wrote:
> Hello.
>
> I just started using Velocity. The text below is taken from the Velocity User Guide. I didn't understand why \\\$email would render as \\\$email. I tried it and it renders as \\$email. Am I missing something?
>
> Cheers,
> Matti Aaltonen
>
>
> Note that the \ character bind to the $ from the left. The bind-from-left rule causes \\\$email to render as \\$email. Compare these examples to those in which > > $email is not defined.
>
> $email
> \$email
> \\$email
> \\\$email
>
> renders as
>
> $email
> \$email
> \\$email
> \\\$email
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
--
:) Christoph Reck
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org