HTL Templates
HTL (Sightly) is AEM's template language. It keeps presentation logic in templates and business logic in Sling Models.
Basics
<div data-sly-use.model="com.example.core.models.MyModel">
<h2>${model.title}</h2>
<p>${model.description}</p>
</div>
Escaping and context
HTL escapes output by default. If you need a specific context (for example, URLs or HTML), use the correct context hint:
<a href="${model.link @ context='uri'}">Read more</a>
Best practices
- Keep logic in Sling Models.
- Avoid string concatenation in templates.
- Use
data-sly-testanddata-sly-listfor conditional rendering and loops.