I have a template called "passTitle" that applies some special formatting to a title element that is used dozens of times in a script. Here's the header for that title:
<template data-sly-template.passTitle="${@title, type}">...</template>
Usually, the title is one string, but sometimes it's multiple things that need to be concatenated. I can't figure out how to get this to work.
Here's the basic call without concatenation, which works fine:
<sly data-sly-call="${passTitle @ title='Title', type='h3'}" />
Here are some of my attempts at a concatenation:
<sly data-sly-test="${showTitle}" data-sly-call="${passTitle @ title=('What is {0}' @format=[data.BaseInfo.ProgramTitle]), type='h3'}" />
<sly data-sly-test="${showTitle}" data-sly-call="${passTitle @ title='What is {0}' @format=[data.BaseInfo.ProgramTitle], type='h3'}" />
<sly data-sly-test="${showTitle}" data-sly-call="${passTitle @ title='What is ' + data.BaseInfo.ProgramTitle}, type='h3'}" />
<sly data-sly-test="${showTitle}" data-sly-call="${passTitle @ title=['What is ', data.BaseInfo.ProgramTitle] @ join='', type='h3'}" />
These give me various errors. My best bet was probably the {0} templating, but that doesn't seem to be supported to the right of '@'
Am I out of luck here?
I know I can do this with a pretty simple js use class, but I'd prefer not to.
Solved! Go to Solution.
There is a thread on Stack Overflow that gives a great answer and helps to explain why you will end up back at smacdonald2008's answer.
Evaluating expression and pass as argument in Sightly AEM - Stack Overflow
Views
Replies
Total Likes
Use JS or Java - HTL syntax is more of a view - it does basic operations (like looping and conditions), but for more complex operations - use JS or Java.
There is a thread on Stack Overflow that gives a great answer and helps to explain why you will end up back at smacdonald2008's answer.
Evaluating expression and pass as argument in Sightly AEM - Stack Overflow
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies