Hello,
I am trying to create html attributes from a string with multiple attributes.
We have a string myAttrs = " class='myClass' id='myId' data-value='myCustomValue'".
I am trying to render that string as attributes of a html element.
Example input: <p ${myAttrs}> My paragraph </p>
Expected output: <p class='myClass' id='myId' data-value='myCustomValue'> My paragraph </p>
That does not work. Is there a sightly command to achieve my expected output without converting the string to a map and using data-sly-attribute?
Thank you
Have a look at data-sly-attribute, you can pass in a map.
https://docs.adobe.com/docs/en/htl/docs/block-statements.html
Views
Replies
Total Likes
Sorry missed you final sentence :-)
Can you try @ context = 'unsafe'?
Views
Replies
Total Likes
I know I can pass a map, but this a integration with a legacy system build using jsp and I would prefer not convert to a map.
Tried 'context' and it didn't work.
Views
Replies
Total Likes
Tried indeed several things, but it isn't working..
What about creating a use-class that converts the String to a Map?
Then your integration can stay as is.
Yeah, that probably is going to be the solution.
I just think it is odd sightly removed a basic jsp functionality.
Views
Replies
Total Likes
Once you get this solution working - enter it into the AEM Immerse contest - we are looking for all sort of workgin AEM Solutions: http://scottsdigitalcommunity.blogspot.ca/2016/12/win-passes-to-experience-manager.html
It may win you access to the AEM Virtual Conference in May where you will get access to lots of awesome AEM sessions.
Views
Replies
Total Likes
Has any one found a solution to this ?
Views
Replies
Total Likes
Use-api to convert String into Hashmap
Views
Replies
Total Likes
Thanks Feike....I made it work like this.
<sly data-sly-test.a=${item.parsysIds}></sly>
<sly data-sly-test.b= "<dd ">
${a @context = 'unsafe'}${b @content='html'} class = "${item.parsysIds} ${wcmmode.edit ? '' : 'hide'}" id="${item.parsysIds}">
It returns me:
<dd notauthenticateduser class="notAuthenticatedUser hide" id="notAuthenticatedUser">
Views
Replies
Total Likes
Only problem with this approach is that the query selector gets updated to all lower case as you might see in the above example(notauthenticateduser).
Do you know if this can be resolved?
Views
Replies
Total Likes
Have you tried doing this use case with Sling Model and use Java logic to perform any data manipulation that you need - or are you trying all data manipulation in HTL syntax.
Views
Replies
Total Likes
For the time-being i am trying only using HTL and the solution worked for me however only issue is that the selector gets updated to lower case..
Views
Replies
Total Likes
One workaround is to use Sling Model and Java and use Java to modify the string to meet your requirements.
Views
Replies
Total Likes
Tried that too. However when i do a ${local Identifier.Object Properties} it returns me a blank. If i do xyz = ${local Identifier.Object Properties} then it renders me the proper authored value.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies