How to split dynamic string value by space in Sightly.
Ex: ${item.fullName} gives 'firstname secondname'. I want to split this by space to get 'firstname' and 'secondname'.
Please help.
Thanks in advance
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Dolly ,
HTL/Sightly is for view/presentation. Let's go one step back, how will you make sure the full name will have only one space in between. Full name can have multiple words (middle name, or sometime more than three). Better you have separate fields in the Sling Model for firstName and lastName (or more) and then use them in HTL.
Though your original question has been answered by @arunpatidar .
This is not possible with Sightly.
This is from official documentation:
Separation of Concerns: The expressiveness of the Sightly template language is purposely limited, in order to make sure that a real programming language is used to express the corresponding presentation logic. This optional logic is invoked from Sightly expressions with the Use-API pattern, making it easy to understand what is called for a given view, and to potentially have different logic for different views of the same resource.
Views
Likes
Replies