You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sven Hall <Sv...@hypercis.de> on 2001/01/05 14:59:32 UTC

#set with string concatenation

Hi,
I'm new to velocity and interested to use it as a code generation tool.

My questions are:

(1)
Why doesn't the #set-statement run with string concatenation?
Here my example

#set ($a = "alpha")
#set ($b = "beta")
#set ($x = "$a" + "/blah/" + "$b")
Result x = $x

(After patching the source ASTAddNode.java it runs for me. I can send the
code changes, if anybody is interested.
I think this is very useful or is there an other way?)

(2)
Should any bugs be reported to the user-list?

Thanks for helping
Sven Hall


Re: #set with string concatenation

Posted by Jon Stevens <jo...@latchkey.com>.
on 1/5/2001 12:32 PM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:

> It wasn't really a fix as much as an extenstion, to make '+' a string
> concatenation operator....

Ah. I thought we already supported that. Oh well.

Hmmm...I think I'm -1 on that given that we already support variables within
quoted strings.

-jon


Re: #set with string concatenation

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jon Stevens wrote:
> 
> on 1/5/2001 6:29 AM, "Christoph Reck" <Ch...@dlr.de> wrote:
> 
> >
> > Just do:
> > #set ($x = "$a/blah/$b")
> 
> Right, but if he has a patch that fixes it, wouldn't you rather have that
> instead of forcing him to use another solution?

It wasn't really a fix as much as an extenstion, to make '+' a string
concatenation operator....


-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

Re: #set with string concatenation

Posted by Jon Stevens <jo...@latchkey.com>.
on 1/5/2001 6:29 AM, "Christoph Reck" <Ch...@dlr.de> wrote:

> 
> Just do:
> #set ($x = "$a/blah/$b")

Right, but if he has a patch that fixes it, wouldn't you rather have that
instead of forcing him to use another solution?

-jon

> 
> Sven Hall wrote:
>> 
>> Hi,
>> I'm new to velocity and interested to use it as a code generation tool.
>> 
>> My questions are:
>> 
>> (1)
>> Why doesn't the #set-statement run with string concatenation?
>> Here my example
>> 
>> #set ($a = "alpha")
>> #set ($b = "beta")
>> #set ($x = "$a" + "/blah/" + "$b")
>> Result x = $x
>> 
>> (After patching the source ASTAddNode.java it runs for me. I can send the
>> code changes, if anybody is interested.
>> I think this is very useful or is there an other way?)
>> 
>> (2)
>> Should any bugs be reported to the user-list?
> 
> If it is something that will imminently affect other users, yes.
> 
>> 
>> Thanks for helping
>> Sven Hall
> 
> :) Christoph
> 

-- 
Honk if you love peace and quiet.



Re: #set with string concatenation

Posted by Christoph Reck <Ch...@dlr.de>.
Just do:
#set ($x = "$a/blah/$b")


Sven Hall wrote:
> 
> Hi,
> I'm new to velocity and interested to use it as a code generation tool.
> 
> My questions are:
> 
> (1)
> Why doesn't the #set-statement run with string concatenation?
> Here my example
> 
> #set ($a = "alpha")
> #set ($b = "beta")
> #set ($x = "$a" + "/blah/" + "$b")
> Result x = $x
> 
> (After patching the source ASTAddNode.java it runs for me. I can send the
> code changes, if anybody is interested.
> I think this is very useful or is there an other way?)
> 
> (2)
> Should any bugs be reported to the user-list?

If it is something that will imminently affect other users, yes.

> 
> Thanks for helping
> Sven Hall

:) Christoph