I have the following code:
<sly data-sly-use.link="${'core.impl.view.tools.LinkUtils' @ path=properties.targetURL}"></sly>
I want to concatenate properties.linkType to properties.targetURL.
Any ideas how it can be done? I've found examples on the net but they don't seem to work for my situation.
Concatenate String Using + Operator The simplest method of adding two strings in C# is using + or += operators.
You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
C++ '+' operator for String Concatenation C++ '+' operator can be used to concatenate two strings easily. The '+' operator adds the two input strings and returns a new string that contains the concatenated string.
I just want to add one more way to concatenate strings to the above answer, by using @ join.
<sly data-sly-test="${['String1','String2','String3'] @ join = '-'}"/>
It will give output as:
String1-String2-String3
That depends on what kind of string concatenation you have in mind:
${properties.targetURL + properties.linkType}<sly data-sly-test.concatenated="${'{0}{1}' @ format=[properties.targetURL, properties.linkType]}"></sly>
${properties.targetUrl}${properties.linkType}
<sly data-sly-use.link="${'core.impl.view.tools.LinkUtils' @ path=properties.targetURL, type=properties.linkType}"></sly>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With