You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steve Cohen <st...@comcast.net> on 2009/01/06 15:28:28 UTC

What's the right way to do this?

Here's the wrong way:

#set ( $text =$velocityCount\) $field.getPaddedLabel($Language): 
$Fields.get($field))
The intent here is to produce a string like

3)    City: Chicago

with a close-paren after the number.

But velocity is complaining about that close parenthesis that I thought 
I was handling via escaping.



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


Re: What's the right way to do this?

Posted by Nathan Bubna <nb...@gmail.com>.
There are no general escaping provisions, and even w/o the close
parenthesis, you would need to put quotes around it.  Can't just put
random content in the RHS of a #set directive.  For an interpolated
string, wrap in ", for a non-interpolated string, wrap in '.
Escaping with \ is only for valid references, directives and
velocimacros.

#set( $text = "$velocityCount) $field.getPaddedLabel($Language):
$Fields.get($field)" )

On Tue, Jan 6, 2009 at 6:28 AM, Steve Cohen <st...@comcast.net> wrote:
> Here's the wrong way:
>
> #set ( $text =$velocityCount\) $field.getPaddedLabel($Language):
> $Fields.get($field))
> The intent here is to produce a string like
>
> 3)    City: Chicago
>
> with a close-paren after the number.
>
> But velocity is complaining about that close parenthesis that I thought I
> was handling via escaping.
>
>
>
> ---------------------------------------------------------------------
> 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: What's the right way to do this?

Posted by Byron Foster <by...@base2.cc>.
Try #set($text = "$velocityCount)")

On Jan 6, 2009, at 7:28 , Steve Cohen wrote:

> Here's the wrong way:
>
> #set ( $text =$velocityCount\) $field.getPaddedLabel($Language):  
> $Fields.get($field))
> The intent here is to produce a string like
>
> 3)    City: Chicago
>
> with a close-paren after the number.
>
> But velocity is complaining about that close parenthesis that I  
> thought I was handling via escaping.


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