What is the difference between: data-sly-use
, data-sly-resource
, data-sly-include
, and data-sly-template
? I am reading the doc on Sightly
AEM
and I am super confused.
As far as I can see:
data-sly-use
is used to add js/java
files to render with the docdata-sly-resource
is used to inject componentsdata-sly-include
is used to include other html files (?***?)And, data-sly-template is confusing, as in:
<div data-sly-use.nav="navigation.js">${nav.foo}</div>
<section data-sly-include="path/to/template.html"></section>
<template data-sly-template.one>blah</template>
<div data-sly-call="${one}"></div>
data-sly-template: Defines a template. The host element and its content are not output by HTL. data-sly-call: Calls a template defined with data-sly-template. The content of the called template (optionally parameterized) replaces the content of the host element of the call.
Helps to add attributes to the host element. For eg: <div title="Page Title" data-sly-attribute.title="${properties.jcr:title}"></div> Prints the current page title, still helpful for searching in html source using term 'Page Title'
data-sly-test - This statement is used to conditionally render a tag and all of it's children. Optionally, it can be used to set a variable as discussed above. data-sly-element - This statement is used to conditionally replace the element type on a tag.
As you already said:
Please refere to the official specs for more informations. there are several examples for each tag:
https://github.com/Adobe-Marketing-Cloud/sightly-spec/blob/master/SPECIFICATION.md
From Docs - https://helpx.adobe.com/experience-manager/htl/using/block-statements.html - data-sly-include: Replaces the content of the host element with the markup generated by the indicated HTML template file (HTL, JSP, ESP etc.) when it is processed by its corresponding template engine. The rendering context of the included file will not include the current HTL context (that of the including file);
The answer is relevant for v6.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With