How to concatenate strings in Sightly/HTL?
sightly
Solution
That depends on what kind of string concatenation you have in mind:
- Concatenating strings using an operator is not supported, ie. you cannot do `${properties.targetURL + properties.linkType}`. A workaround (suggested by @Jens) is to do something like: `<sly data-sly-test.concatenated="${'{0}{1}' @ format=[properties.targetURL, properties.linkType]}"></sly>`
- Concatenating strings in HTML output can be done by placing HTL expression next to each other, ie. `${properties.targetUrl}${properties.linkType}`
- Sending both strings to an Use Object is supported via multiple expression options: `<sly data-sly-use.link="${'core.impl.view.tools.LinkUtils' @ path=properties.targetURL, type=properties.linkType}"></sly>`
- Concatenating strings to form an URL might be possible in some cases using URI Manipulation
Problem
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.