velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apa...@recks.org
Subject Re: Global variables
Date Wed, 31 May 2006 10:57:21 GMT
Hi,

Daniel Pfeifer wrote:
> Well, no, it really doesn't make sense why string concatenation doesn't
> work ;)

Depends on from where you come and on your point of view.
The syntax for string catenation in Velocity is widely
used.

> 
> However, I'll simply do as you suggested.
> 
> /Daniel


Every language has its own syntax for string concatenation:

- Perl uses "." or interpolation:
    $c = $a.$b;
    $c = "$a$b";

- Java(Script) uses "+":
    String c = a + b;

- C++ streams use "<<" for string catenation.

- Unix shells, unix-tools and pre-processors (sh, bash,
   *sh, *csh, *awk, m4, cpp) use no catenation symbol and
   encapsulates the references if needed:
    c = $a$b
    c = "$a$b"
    c = "a=${a}, b=${b}"

- Velocity is unix-tool-like, with a small flavor of perl!

Cheers,
Christoph

> -----Original Message-----
> From: trad-ex [mailto:trad-ex@inter7.jp] 
> Sent: den 31 maj 2006 08:10
> To: Velocity Users List
> Subject: RE: Global variables
> 
> Hi Daniel,
> 
> It's the same, IMHO.
> 
> #if ($pId)
>   #set ($tempLink = "$tempLink&p=${pId}" )
> #end
> #if ($preurl)
>   #set ($tempLink = "$!preurl$tempLink")
> #end
> $!{tempLink}
> 
> Doesn't it make sense ?
> 
> Best Regards,
> trad-ex
> 
> 
>> If I'd like to increase readability (in my example I only included two
>> of the total of five #set-directives), how should I do? It must be
>> possible somehow to change the $tempLink from within the if-block.
>>
>> -----Original Message-----
>> From: trad-ex [mailto:trad-ex@inter7.jp] 
>> Sent: den 31 maj 2006 06:52
>> To: Velocity Users List
>> Subject: Re: Global variables
>>
>> Hi, Daniel,
>>
>> Try it below !
>>
>> #set($tempLink = "$!preurl$tempLink$!pId")
>>
>> Best Regards
>> trad-ex
>>
>>> Hi,
>>>
>>> this must be a frequent question but I couldn't find an answer to it
> on
>> the
>>> website.
>>>
>>> I've got following velocity template:
>>>
>>> #set ($tempLink =
>> "http://${subdomain}.tradedoubler.com/tr?a=${aId}&c=${cId
>>> }")
>>> #if ($pId)
>>>  #set ($tempLink = $tempLink + "&p=${pId}")
>>> #end
>>> #if ($preurl)
>>>  #set ($tempLink = $preurl + $tempLink)
>>> #end
>>> $!{tempLink}
>>>
>>>
>>> The fact of the matter is: Even though neither $pId or $preurl is null
>> (I 
>>> verified this and yes, it does enter the #if-blocks) the resulting
>> tempLink
>>> is always
>>>
>>> http://se.tradedoubler.com/tr?a=239&c=39433
>>>
>>> The question is: Why don't the subsequent #set-directives change the
>> value 
>>> of $tempLink?
>>>
>>> Thanks in advance,
>>> Daniel Pfeifer
>> ---------------------------------------------------------------------
>> 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
> 
> ---------------------------------------------------------------------
> 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
> 
> 

---------------------------------------------------------------------
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