velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Dekany <ddek...@freemail.hu>
Subject Re: escaping examples in the user guide are not right
Date Tue, 12 Oct 2004 18:05:28 GMT
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 <shinobu.kawai@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


Mime
View raw message