51黑料不打烊

AEM Extensions aem-extensions

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

i18n i18n

The same 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 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 or . With both approaches, the resourceName String property must be provided. Its value is used to create a that is included in the rendering context. The rest of the properties from the Record or the Map passed to data-sly-resource are used as normal Resource properties. If the sling:resourceType property is missing from this map, the resource type is assumed to be either the value of the resourceType 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