HTL formatting



HTL Url formatting
HTL allows rich way of URL Formatting.

HTML Extension
<a href="${item.path @ extension = 'html'}">${item.name}</a>
Adds the html extension to a path.

<a href="${item.path @ extension = 'html', selectors='products'}">${item.name}</a>
Adds the html extension and a selector to a path.

<a href="${item.path @ extension = 'html', fragment=item.name}">${item.name}</a>
Adds the html extension and a fragment (#value) to a path.

HTL Date & Number formatting
The latest AEM versions supports numbers and dates formatting which includes timezone and locale formatting. We dont have to write custom code any more. The syntax for formatting is format is specified first, then the value which needs to be formatted.

For eg
Date formatting
<h6>${ 'dd-MMMM-yyyy hh:mm:ss' @ format=currentPage.lastModified, timezone='PST', locale='fr'}</h6>

Number formatting 
<h6>${ '#.00' @ format=500}</h6>

Go to HTL Tutorial Home page

 

No comments:

Post a Comment