Search code examples
adobeaemternary-operatorstring-concatenationhtl

HTL Language, string concatenation and ternary operator


I am using adobe AEM, and the HTL language. I am writing something like:

${properties.hash ? [model1.href,properties.hash] @ join='#' : model1.href}

But doesn't works. I think it is a syntax problem.. But I am not able to solve the problem.


Solution

  • @ token in ternary expression is not a valid token at this place. You can move the @join to end of expression.

     ${properties.hash ? [model1.href,properties.hash] : model1.href @ join='#'}
    

    @join doesn't impacts simple string, leaves as it is, which would the case if properties.hash is false