In a component when you find a tag whit a text in an AEM component. | Community
Skip to main content
April 5, 2024
Solved

In a component when you find a tag whit a text in an AEM component.

  • April 5, 2024
  • 1 reply
  • 559 views

I will like to have the possiblity to have my component to replace the tag whit a text 

For example: "this is a [tag] text"  (tag=normal ) 

in "this is a normal text " , i can replace the string and take the data from a content fragment but i'm not able to modify the text in a component 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

Hi, 

You could use a Sling Model to manually perform the replacement. Simply put, in the Sling Model, look for the property that contains the "[tag]" and replace it with any other value you need. Then return the new value and use it in your HTL.


Here you have an example of a sling model that can be useful: https://sourcedcode.com/blog/aem/how-to-pass-parameters-to-sling-modal-from-sightly-htl-component 


Hope this helps.

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
April 8, 2024

Hi, 

You could use a Sling Model to manually perform the replacement. Simply put, in the Sling Model, look for the property that contains the "[tag]" and replace it with any other value you need. Then return the new value and use it in your HTL.


Here you have an example of a sling model that can be useful: https://sourcedcode.com/blog/aem/how-to-pass-parameters-to-sling-modal-from-sightly-htl-component 


Hope this helps.

Esteban Bustamante