Expand my Community achievements bar.

SOLVED

Unwrap data-sly-resource

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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>

 

 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

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>

 

 

Avatar

Level 2

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

Avatar

Community Advisor

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-compone...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/using-data-sly-element-and...

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

Regards,

Shiv

 

 

Shiv Prakash