Unwrap data-sly-resource | Community
Skip to main content
Level 2
May 22, 2023
Solved

Unwrap data-sly-resource

  • May 22, 2023
  • 2 replies
  • 3498 views

Hi,

I need to use data-sly-resource to import some custom components. 

I'm using this snippet:

 

 

<div data-sly-resource="${'link' @ resourceType='my-project/components/link-large', decoration=true}" data-sly-unwrap></div>

 

In this case the data-sly-unwrap attribute doesn't seems to work. The result is:

 

<div class="link"> <a>...mycomponent</a> </div>

 

What I missed?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by MayurSatav

hi @giuderos1 ,

 

The data-sly-unwrap attribute in HTL is used to remove the wrapping element when including a resource using data-sly-resource. In your case, it seems that the data-sly-unwrap attribute is not working as expected.

 

Simply use - 

 

 

<sly data-sly-resource="${'link' @ resourceType='my-project/components/link-large', decoration=true}"></sly>

 

 

2 replies

MayurSatav
Community Advisor and Adobe Champion
MayurSatavCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 22, 2023

hi @giuderos1 ,

 

The data-sly-unwrap attribute in HTL is used to remove the wrapping element when including a resource using data-sly-resource. In your case, it seems that the data-sly-unwrap attribute is not working as expected.

 

Simply use - 

 

 

<sly data-sly-resource="${'link' @ resourceType='my-project/components/link-large', decoration=true}"></sly>

 

 

Mayur Satav | www.mayursatav.in
Giuderos1Author
Level 2
May 23, 2023

Sorry, but even this solution is not working, the wrapping div is still there

Shiv_Prakash_Patel
Community Advisor
Community Advisor
May 22, 2023

Hi @giuderos1 ,

You can use data-sly-unwrap="${true}", It will work.

<div data-sly-resource="${'link' @ resourceType='my-project/components/link-large', decoration=true}" data-sly-unwrap="${true}"></div>

To understand more about data-sly-resource 7 data-sly-unwrap, please check below thread.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-include-one-component-within-another-component/m-p/463370

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/using-data-sly-element-and-data-sly-unwrap-creates-malfromed/td-p/316689

https://www.aemtutorial.info/p/htl-sly-unwrap.html

Regards,

Shiv

 

 

Shiv Prakash