Skip to content

Instantly share code, notes, and snippets.

@kevinweber
Last active May 5, 2023 12:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save kevinweber/c0004e7066306821d565d57fd37ccef7 to your computer and use it in GitHub Desktop.
Save kevinweber/c0004e7066306821d565d57fd37ccef7 to your computer and use it in GitHub Desktop.
AEM: Include another resource + modify tag and class name #data-sly-resource
<!--/* More: https://docs.adobe.com/docs/en/htl/docs/block-statements.html#resource */-->
<!--/* By default, the AEM decoration tags are disabled, the decorationTagName option allows to bring them back, and the cssClassName to add classes to that element. */-->
<div data-sly-resource="${'headline' @
resourceType='about-project/components/content/c34-section-headline',
decorationTagName='span',
cssClassName='className'
}"></div>
<!--/* More about the decoration tag: https://docs.adobe.com/docs/en/aem/6-3/develop/components/decoration-tag.html */-->
<!--/* This allows you to include tags from the included resource's _cq_htmlTag.html. */-->
<!--/* If there is more than one resource, wrap each in `sly` tags so the decoration tag gets applied to all of them, not just the first one. */-->
<sly>
<div data-sly-resource="${'problem' @resourceType='path/to/resource', decoration=true}"></div>
</sly>
<sly>
<div data-sly-resource="${'solution' @resourceType='path/to/another/resource', decoration=true}"></div>
</sly>
<!--/* About Sling selectors: https://sling.apache.org/documentation/the-sling-engine/url-decomposition.html */-->
<article data-sly-resource="${'path/to/resource' @ selectors='selector'}"></article>
<article data-sly-resource="${'path/to/resource' @ selectors=['s1', 's2']}"></article>
<article data-sly-resource="${'path/to/resource' @ addSelectors='selector'}"></article>
<article data-sly-resource="${'path/to/resource' @ removeSelectors='selector1'}"></article>
<!--/* Remove all selectors: */-->
<article data-sly-resource="${'path/to/resource' @ removeSelectors}"></article>
<!--/* Change the WCM mode of an included resource: */-->
<article data-sly-resource="${'path/to/resource' @ wcmmode='disabled'}"></article>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment