Reputation: 6675
Using HTL (Sightly) I want to display
<h2 data-sly-text="${model.heading}"></h2>
But only if the ${model.heading}
is not empty, otherwise nothing, not even the h2
tag.
I tried the following solution, but it didn't work:
<sly data-sly-test="${model.heading}"><h2 data-sly-text="${model.heading}"></h2></sly>
Upvotes: 1
Views: 85
Reputation: 10780
You can just write it as:
<h2 data-sly-test="${model.heading}" data-sly-text="${model.heading}">Heading placeholder</h2>
The snippet you posted should have worked too, since you did not mention what was not working I can suggest:
model
variable is properly defined and initialisedheading
property is properly exposed (either directly or via a getHeading
method)Upvotes: 2