cq:template values are not rendering | Community
Skip to main content
Level 3
January 6, 2025
Solved

cq:template values are not rendering

  • January 6, 2025
  • 3 replies
  • 682 views

<div data-sly-resource="${'inlinesubscribe' @ resourceType='abc/components/content/inlinesubscribe'}"></div>
<div data-sly-resource="${'inlinesocial' @ resourceType='abc/components/content/inlinesocial'}"></div>

im adding this code to configure inlinesubscribe and inlinesocial component inside another component.. these two components is having cq:template default values.
but those are not rendering if i add it inside another component.
individually its working fine.

Best answer by arunpatidar

Hi @sudarshanv1 

It will not work if component is embedded within another component.

In this case you need to add cq:template to parent component with content structure e.g.

https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/ui.apps/src/main/content/jcr_root/apps/aemlab/oneweb/components/tabs/_cq_template/.content.xml 

3 replies

partyush
Community Advisor
Community Advisor
January 6, 2025

Hi @sudarshanv1 

Use data-sly-include Instead
Replace data-sly-resource with data-sly-include to include rendered content with default properties:

 

<div data-sly-include="${'/content/path/to/inlinesubscribe' @ resourceType='abc/components/content/inlinesubscribe'}"></div> <div data-sly-include="${'/content/path/to/inlinesocial' @ resourceType='abc/components/content/inlinesocial'}"></div>

 

Pass Default Properties Manually
If defaults aren’t applied, explicitly pass them in data-sly-resource:

 

<div data-sly-resource="${'inlinesubscribe' @ resourceType='abc/components/content/inlinesubscribe', prop1='default1'}"></div> <div data-sly-resource="${'inlinesocial' @ resourceType='abc/components/content/inlinesocial', prop1='default1'}"></div>

 

Check Policies & Resource Inheritance
Ensure proper template policies and sling:resourceSuperType for both components.

Debug Properties
Use ${properties @ context='json'} in the child components to verify passed values.

Please let me know if you need further help 

Thanks

Partyush

 



 

SreenivasBr
Level 4
January 6, 2025

Is the parent component a container component? Refer this for including a component inside another component - https://medium.com/@arunpatidar26/cq-iscontainer-property-in-aem-94e5318e04fa

 

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
January 7, 2025

Hi @sudarshanv1 

It will not work if component is embedded within another component.

In this case you need to add cq:template to parent component with content structure e.g.

https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/ui.apps/src/main/content/jcr_root/apps/aemlab/oneweb/components/tabs/_cq_template/.content.xml 

Arun Patidar
Level 3
January 8, 2025

thanks this works