AEM Extensions aem-extensions

Similar to the Apache Sling extensions of the HTL specification, AEM offers some additional expression options that make working with AEM concepts a bit easier directly in the HTL scripts.

i18n i18n

The same three additional options as in Apache Sling can be used together with i18n:

  • locale
  • hint
  • basename

However in AEM, the internationalization support for HTL is implemented with the help of the API from the com.day.cq.i18n package.

data-sly-include data-sly-include

In AEM, data-sly-include can take an additional wcmmode option that control the WCM Mode for the included script. The allowed values are the names of the available enum constants.

data-sly-resource data-sly-resource

In addition to paths and Resources, the data-sly-resource block element can also work with Maps or Records. With both approaches, the resourceName String property must be provided. Its value is used to create a Synthetic Resource that will be included in the rendering context. The rest of the properties from the Record or the Map that was passed to data-sly-resource will be used as normal Resource properties. If the sling:resourceType property is missing from this map, the resource type will be assumed to be either the value of the resourceType expression option or the resource type of the current resource that drives the rendering.

Given the following map/record properties available in the script scope as map:

{
    resourceName: "myText",
    "sling:resourceType": "core/wcm/components/text/v2/text",
    "text": "Hello World!"
}

And given the following markup:

<div class="outer" data-sly-resource="${map}"></div>

The following output is expected:

<div class="outer">
    <div class="myText">
        <div data-cmp-data-layer="{&quot;text-e58d65c472&quot;:{&quot;@type&quot;:&quot;core/wcm/components/text/v2/text&quot;,&quot;xdm:text&quot;:&quot;<p>Hello world!</p>&quot;}}" id="text-e58d65c472" class="cmp-text">
            <p>Hello world!</p>
        </div>
  </div>
</div>
recommendation-more-help
86859df1-0285-4512-b293-0ef9cbea5ee8