You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Shinobu Kawai <sh...@gmail.com> on 2004/10/10 05:33:27 UTC

escaping examples in the user guide are not right

Hi all,

The escaping feature has gotten me half-way up the wall.  I tried the
examples in the user guide with the following results.

Escaping Valid VTL References
 http://jakarta.apache.org/velocity/user-guide.html#Escaping%20Valid%20VTL%20References
The first one works fine, but the second:

$email
\$email
\\$email
\\\$email

renders as

$email
\$email
\\$email
\\$email

instead of the documented

$email
\$email
\\$email
\\\$email

What's wrong with the last line?


Escaping VTL Directives
 http://jakarta.apache.org/velocity/user-guide.html#Escaping%20VTL%20Directives
(I used #set instead.)  According to the guide,

#set($foo1 = "bar")
\#set($foo2 = "bar")
\\#set($foo3 = "bar")

should render as

<setting foo1, so nothing rendered and line feed omitted>
\#set($foo2 = "bar2")
\<setting foo3, so nothing rendered and line feed omitted>

but was

#set($foo2 = "bar2")
\\

Where did the backslash go on the second line, and where did the extra
backslash come from on the third?


Advanced Issues: Escaping and !
 http://jakarta.apache.org/velocity/user-guide.html#Advanced%20Issues:%20Escaping%20and%20!
This was the only one that gave the same output as the example.


Can anybody clarify this complicated mechanism?

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

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


Re: escaping examples in the user guide are not right

Posted by Daniel Dekany <dd...@freemail.hu>.
Tuesday, October 12, 2004, 6:33:21 PM, Tim Colson wrote:

> I can't explain the escaping... and I've got one more question to add...
>
> Why do unassigned vars like \$empty NOT produce $empty?
>
> #set ($foo = "this is foo")
> \$foo = $foo
> \$empty = $empty
> ----
> Expected this:
> $foo = this is foo
> $empty = $empty
>
> Got this:
> $foo = this is foo
> \$empty = $empty
>
> Seems \ only 'escapes' the $ if $thingy has a value.

An important design goal of Velocity was to make your life more
interesting an happy with language design gems like this. My conclusion
was not using escaping... put a dollar variable into the context
(${D}empty), or something like that.

> I often want to document the context items on the page so the HTML folks
> know what 'will' be available. It is annoying to be forced to assign values
> to the variables so the docs look okay. :-(

Do not be said. This is funny. What does \$empty do? Hey, it depends on
the template context! So playful! :)

> Tim
>
>
>> -----Original Message-----
>> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com] 
>> Sent: Saturday, October 09, 2004 8:33 PM
>> To: Velocity Users List
>> Subject: escaping examples in the user guide are not right
>> 
>> Hi all,
>> 
>> The escaping feature has gotten me half-way up the wall.  I tried the
>> examples in the user guide with the following results.
>> 
>> Escaping Valid VTL References
>>  
>> http://jakarta.apache.org/velocity/user-guide.html#Escaping%20
>> Valid%20VTL%20References
>> The first one works fine, but the second:
>> 
>> $email
>> \$email
>> \\$email
>> \\\$email
>> 
>> renders as
>> 
>> $email
>> \$email
>> \\$email
>> \\$email
>> 
>> instead of the documented
>> 
>> $email
>> \$email
>> \\$email
>> \\\$email
>> 
>> What's wrong with the last line?
>> 
>> 
>> Escaping VTL Directives
>>  
>> http://jakarta.apache.org/velocity/user-guide.html#Escaping%20
>> VTL%20Directives
>> (I used #set instead.)  According to the guide,
>> 
>> #set($foo1 = "bar")
>> \#set($foo2 = "bar")
>> \\#set($foo3 = "bar")
>> 
>> should render as
>> 
>> <setting foo1, so nothing rendered and line feed omitted>
>> \#set($foo2 = "bar2")
>> \<setting foo3, so nothing rendered and line feed omitted>
>> 
>> but was
>> 
>> #set($foo2 = "bar2")
>> \\
>> 
>> Where did the backslash go on the second line, and where did the extra
>> backslash come from on the third?
>> 
>> 
>> Advanced Issues: Escaping and !
>>  
>> http://jakarta.apache.org/velocity/user-guide.html#Advanced%20
>> Issues:%20Escaping%20and%20!
>> This was the only one that gave the same output as the example.
>> 
>> 
>> Can anybody clarify this complicated mechanism?
>> 
>> Best regards,
>> -- Shinobu Kawai
>> 
>> -- 
>> Shinobu Kawai <sh...@gmail.com>
>> 
>> ---------------------------------------------------------------------
>> 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

-- 
Best regards,
 Daniel Dekany


____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu

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


RE: escaping examples in the user guide are not right

Posted by Tim Colson <tc...@cisco.com>.
I can't explain the escaping... and I've got one more question to add...

Why do unassigned vars like \$empty NOT produce $empty?

#set ($foo = "this is foo")
\$foo = $foo
\$empty = $empty
----
Expected this:
$foo = this is foo
$empty = $empty

Got this:
$foo = this is foo
\$empty = $empty

Seems \ only 'escapes' the $ if $thingy has a value.

I often want to document the context items on the page so the HTML folks
know what 'will' be available. It is annoying to be forced to assign values
to the variables so the docs look okay. :-(

Tim


> -----Original Message-----
> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com] 
> Sent: Saturday, October 09, 2004 8:33 PM
> To: Velocity Users List
> Subject: escaping examples in the user guide are not right
> 
> Hi all,
> 
> The escaping feature has gotten me half-way up the wall.  I tried the
> examples in the user guide with the following results.
> 
> Escaping Valid VTL References
>  
> http://jakarta.apache.org/velocity/user-guide.html#Escaping%20
> Valid%20VTL%20References
> The first one works fine, but the second:
> 
> $email
> \$email
> \\$email
> \\\$email
> 
> renders as
> 
> $email
> \$email
> \\$email
> \\$email
> 
> instead of the documented
> 
> $email
> \$email
> \\$email
> \\\$email
> 
> What's wrong with the last line?
> 
> 
> Escaping VTL Directives
>  
> http://jakarta.apache.org/velocity/user-guide.html#Escaping%20
> VTL%20Directives
> (I used #set instead.)  According to the guide,
> 
> #set($foo1 = "bar")
> \#set($foo2 = "bar")
> \\#set($foo3 = "bar")
> 
> should render as
> 
> <setting foo1, so nothing rendered and line feed omitted>
> \#set($foo2 = "bar2")
> \<setting foo3, so nothing rendered and line feed omitted>
> 
> but was
> 
> #set($foo2 = "bar2")
> \\
> 
> Where did the backslash go on the second line, and where did the extra
> backslash come from on the third?
> 
> 
> Advanced Issues: Escaping and !
>  
> http://jakarta.apache.org/velocity/user-guide.html#Advanced%20
> Issues:%20Escaping%20and%20!
> This was the only one that gave the same output as the example.
> 
> 
> Can anybody clarify this complicated mechanism?
> 
> Best regards,
> -- Shinobu Kawai
> 
> -- 
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> 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