What is the difference between data-sly-use, data-sly-resource, data-sly-include, and data-sly-template?

Hello Universe picture Hello Universe · Oct 28, 2015 · Viewed 29.1k times · Source

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 doc
  • data-sly-resource is used to inject components
  • data-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>

Answer

chrysler picture chrysler · Oct 28, 2015

As you already said:

  • data-sly-use "is used to add js/java". You declare component-beans with this statement for instance.
  • data-sly-resource you can override a resource-type for a included file.
  • data-sly-include includes other html files as the name suggests.
  • data-sly-template you declare templates which can later be 'called' with data-sly-call.

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