AEM Sightly Comments with Examples

When writing comments in your Sightly HTL file, it’s best practice not to use HTML comments, but to use the sightly, HTML Template Language.

1. HTL comments are not evaluated and returned back as an empty string in the server-side rendered results.

This is best practice when developers are including some comments for other developers in their organization.

Sightly HTL comments combine HTML and JavaScript multi-line comments: <!–/* */–>

1
2
3
4
5
6
7
8
9
10
11
<!--/* The content of this comment will be removed from the output. */-->
// output: ""

<!--/*
      The content of this comment will be removed from the output.
      The content of this comment will be removed from the output.
      The content of this comment will be removed from the output.
      The content of this comment will be removed from the output.
      Page title: ${currentPage.jcr:title}
*/-->
// output: ""

2. Standard HTML comments, the comments are evaluated and are server-side rendered with the expected results.

1
2
3
<!-- Page title: ${currentPage.jcr:title} -->

//output <!-- Page title: Home Page -->

Available for HTML Template Language Specification 1.4
Release Date: 18 June 2018
Reference: https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md


Looking for Help? Or need a mentor?

If you need help to super drive your AEM career road map, you can hire me for a one-hour session on codementor.io; We can work together on a price works just for you. https://www.codementor.io/@briankasingli. I'd be happy to help you along your way to becoming a high-quality AEM full-stack engineer.

Was this post helpful?

Hello, I am an enthusiastic Adobe Community Advisor and a seasoned Lead AEM Developer. I am currently serving as an AEM Technical Lead at MNPDigital.ca, bringing over a decade of extensive web engineering experience and more than eight years of practical AEM experience to the table. My goal is to give back to the AEM Full Stack Development community by sharing my wealth of knowledge with others. You can connect with me on LinkedIn.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top