You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Geir Magnusson Jr <ge...@4quarters.com> on 2003/12/23 17:38:04 UTC

Re: Change to allow newlines in directives and + as a string conc atenator

yes, that might be useful too :)

On Dec 23, 2003, at 11:29 AM, Ryan Lea wrote:

> Are there any plans to extend this functionality to allow the  
> following:
>
> $link.setPage(<some stuff>)
> .addQueryData(<some stuff>)
> .addQueryData(<more stuff>)
>
> Etc?  It would be quite useful if a character could be used to allow
> multiple line statements for example '/', as this would then allow  
> *any*
> line to be continued to the next ...
>
> -----Original Message-----
> From: Geir Magnusson Jr [mailto:geir@4quarters.com]
> Sent: 23 December 2003 4:14 PM
> To: Velocity Users List
> Subject: Re: Change to allow newlines in directives and + as a string
> concatenator
>
>
>
> On Dec 23, 2003, at 11:10 AM, Andy Lee wrote:
>
>> Geir Magnusson Jr wrote:
>>
>>> The first is that you can use newlines in directives
>>>
>>> #foreach($foo
>>> in
>>> $bar)
>>
>>
>> I assume ## comments will work as expected?  For example:
>>
>> #foreach( $capital in [
>>    "Albany",        ## New York
>>    "Little Rock",   ## Arkansas
>>    "Boise"          ## Idaho
>> ])
>>
>
> No, not yet.
>
>>> The second, which I think we should agree on, is to use '+' as the
>>> string concatenation operator, so you can :
>>>
>>> #set($longstring = "this is a long "
>>>        + "string that you can do over "
>>>        + "multiple lines")
>>>
>>> Comments?
>>>
>> Can the operands be variables?  If so, what if one of the operands is
>> a numeric type?  For example:
>>
>> #set( $newFileName = $prefix + $oldFileName )
>>
>> Would the results of this depend on whether the value of $prefix is 3
>> or "3"?
>
> Yes - they can be vars, and if one is a string, then they other's
> string rep is concatenated
>
>>
>> --Andy
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
> --  
> Geir Magnusson Jr                                   203-247-1713(m)
> geir@4quarters.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
> _______________________________________________________________________ 
> _
> This email has been scanned for all viruses by the MessageLabs service.
>
>
> _______________________________________________________________________ 
> _
> This email has been scanned for all viruses by the MessageLabs service.
> _______________________________________________________________________ 
> _
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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


Re: Change to allow newlines in directives and + as a string conc atenator

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Dec 23, 2003, at 1:24 PM, Mike Kienenberger wrote:

> Will Glass-Husain <wg...@forio.com> wrote:
>> Just as a note, even spaces aren't allowed before method calls.  So, 
>> it's
>> consistent.  It seems useful, but I question whether there's a risk 
>> that
> any
>> period after a velocity call (no matter how many spaces or periods in
>> between) might be misinterpreted as a method/property reference.
>
> I think you'd have to limit newline inclusion to the formal notation to
> remove that risk.
>
> Once you know you're in the context of a formal notation grammar 
> element, it
> should be possible to allow white-space, comments, etc.

But we hate formal notation :)

>
> -Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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


Re: Change to allow newlines in directives and + as a string concatenator

Posted by Nathan Bubna <na...@esha.com>.
Mike Kienenberger said:
> Will Glass-Husain <wg...@forio.com> wrote:
> > Just as a note, even spaces aren't allowed before method calls.  So, it's
> > consistent.  It seems useful, but I question whether there's a risk that
> any
> > period after a velocity call (no matter how many spaces or periods in
> > between) might be misinterpreted as a method/property reference.
>
> I think you'd have to limit newline inclusion to the formal notation to
> remove that risk.
>
> Once you know you're in the context of a formal notation grammar element, it
> should be possible to allow white-space, comments, etc.

yeah, that makes sense.  i don't see any problem with:

${link.setPage("foo")
      .addQueryData("bar","baz")}

i probably wouldn't use it, but it keeps treating newlines as whitespace, it's
clear what is intended.

Nathan Bubna
nathan@esha.com


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


Re: Change to allow newlines in directives and + as a string conc atenator

Posted by Mike Kienenberger <mk...@alaska.net>.
Will Glass-Husain <wg...@forio.com> wrote:
> Just as a note, even spaces aren't allowed before method calls.  So, it's
> consistent.  It seems useful, but I question whether there's a risk that 
any
> period after a velocity call (no matter how many spaces or periods in
> between) might be misinterpreted as a method/property reference.

I think you'd have to limit newline inclusion to the formal notation to 
remove that risk.

Once you know you're in the context of a formal notation grammar element, it 
should be possible to allow white-space, comments, etc.

-Mike

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


Re: Change to allow newlines in directives and + as a string conc atenator

Posted by Will Glass-Husain <wg...@forio.com>.
Just as a note, even spaces aren't allowed before method calls.  So, it's
consistent.  It seems useful, but I question whether there's a risk that any
period after a velocity call (no matter how many spaces or periods in
between) might be misinterpreted as a method/property reference.


----- Original Message ----- 
From: "Geir Magnusson Jr" <ge...@4quarters.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, December 23, 2003 8:38 AM
Subject: Re: Change to allow newlines in directives and + as a string conc
atenator


> yes, that might be useful too :)
>
> On Dec 23, 2003, at 11:29 AM, Ryan Lea wrote:
>
> > Are there any plans to extend this functionality to allow the
> > following:
> >
> > $link.setPage(<some stuff>)
> > .addQueryData(<some stuff>)
> > .addQueryData(<more stuff>)
> >
> > Etc?  It would be quite useful if a character could be used to allow
> > multiple line statements for example '/', as this would then allow
> > *any*
> > line to be continued to the next ...
> >
> > -----Original Message-----
> > From: Geir Magnusson Jr [mailto:geir@4quarters.com]
> > Sent: 23 December 2003 4:14 PM
> > To: Velocity Users List
> > Subject: Re: Change to allow newlines in directives and + as a string
> > concatenator
> >
> >
> >
> > On Dec 23, 2003, at 11:10 AM, Andy Lee wrote:
> >
> >> Geir Magnusson Jr wrote:
> >>
> >>> The first is that you can use newlines in directives
> >>>
> >>> #foreach($foo
> >>> in
> >>> $bar)
> >>
> >>
> >> I assume ## comments will work as expected?  For example:
> >>
> >> #foreach( $capital in [
> >>    "Albany",        ## New York
> >>    "Little Rock",   ## Arkansas
> >>    "Boise"          ## Idaho
> >> ])
> >>
> >
> > No, not yet.
> >
> >>> The second, which I think we should agree on, is to use '+' as the
> >>> string concatenation operator, so you can :
> >>>
> >>> #set($longstring = "this is a long "
> >>>        + "string that you can do over "
> >>>        + "multiple lines")
> >>>
> >>> Comments?
> >>>
> >> Can the operands be variables?  If so, what if one of the operands is
> >> a numeric type?  For example:
> >>
> >> #set( $newFileName = $prefix + $oldFileName )
> >>
> >> Would the results of this depend on whether the value of $prefix is 3
> >> or "3"?
> >
> > Yes - they can be vars, and if one is a string, then they other's
> > string rep is concatenated
> >
> >>
> >> --Andy
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >>
> > -- 
> > Geir Magnusson Jr                                   203-247-1713(m)
> > geir@4quarters.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> > _______________________________________________________________________
> > _
> > This email has been scanned for all viruses by the MessageLabs service.
> >
> >
> > _______________________________________________________________________
> > _
> > This email has been scanned for all viruses by the MessageLabs service.
> > _______________________________________________________________________
> > _
> >
> -- 
> Geir Magnusson Jr                                   203-247-1713(m)
> geir@4quarters.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