data-sly-resource attributes | Community
Skip to main content
Level 3
October 16, 2015
Solved

data-sly-resource attributes

  • October 16, 2015
  • 5 replies
  • 37978 views

I have just come across this URL which briefs about the sightly syntax. But I am still not clear with some of the attributes that could be used along with data-sly-resource. Could you please explain the use cases for these options.

Reference URL: http://stackoverflow.com/questions/27583326/expression-option-sightly

data-sly-resource:

  • selectors: To replace the selectors.
  • addSelectors: To add selectors.
  • removeSelectors: To remove selectors.
  • resourceType: To define or change the resource type (only needed if not already defined as needed on the content node).
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 Feike_Visser1

the resourceType-option comes handy if you want to point to a different 'component' to render your node, other than the one specified via sling:resourceType on the node level.

<div data-sly-resource="${ 'foo' }"></div> renders the 'foo' node via the component specified at sling:resourceType

<div data-sly-resource="${ 'foo' @ resourceType='a/b/c/d' }"></div> renders the 'foo' node via the component a/b/c/d

5 replies

Feike_Visser1
Adobe Employee
Adobe Employee
October 16, 2015
Level 3
October 16, 2015

Hi Feike,

Thanks for the quick response.

I have gone through this page already. However I am still not very clear with some of the options which are highlighted again below. I have added some questions in the parenthesis below to make the question bit more clear if it wasn't before.  

data-sly-resource:

  • selectors: To replace the selectors.(any example to understand how this works?)
  • addSelectors: To add selectors.(any example to understand how this works?)
  • removeSelectors: To remove selectors. (any example to understand how this works?)
  • resourceType: To define or change the resource type ( how could be change the resourceType? )

For e.g. I know that resourceType option could be used to include a component in the page like a <cq:include path="foo" resourceType="sample/components/foo/bar" /> which have the sightly syntax like below which creates a node 'foo' to store any dialog properties for the component 'sample/components/foo/bar'. 

<div data-sly-resource="${'foo' @ resourceType='sample/components/foo/bar'}"></div>

Sorry if this is a basic question as I have not used it before.

popescu_cristi1
October 16, 2015

coolpaul wrote...

Hi Feike,

Thanks for the quick response.

I have gone through this page already. However I am still not very clear with some of the options which are highlighted again below. I have added some questions in the parenthesis below to make the question bit more clear if it wasn't before.  

data-sly-resource:

  • selectors: To replace the selectors.(any example to understand how this works?)
  • addSelectors: To add selectors.(any example to understand how this works?)
  • removeSelectors: To remove selectors. (any example to understand how this works?)
  • resourceType: To define or change the resource type ( how could be change the resourceType? )

For e.g. I know that resourceType option could be used to include a component in the page like a <cq:include path="foo" resourceType="sample/components/foo/bar" /> which have the sightly syntax like below which creates a node 'foo' to store any dialog properties for the component 'sample/components/foo/bar'. 

<div data-sly-resource="${'foo' @ resourceType='sample/components/foo/bar'}"></div>

Sorry if this is a basic question as I have not used it before.

 

nice

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

the resourceType-option comes handy if you want to point to a different 'component' to render your node, other than the one specified via sling:resourceType on the node level.

<div data-sly-resource="${ 'foo' }"></div> renders the 'foo' node via the component specified at sling:resourceType

<div data-sly-resource="${ 'foo' @ resourceType='a/b/c/d' }"></div> renders the 'foo' node via the component a/b/c/d

Level 3
October 16, 2015

Hi Feike,

Thanks very much for clarifying this. This gives me a better idea about how the tag works with/without resourceType attribute. :)

I have found a Stackoverflow question which would give some contextual knowledge regarding the same and might be useful for some - http://stackoverflow.com/questions/23530232/how-to-properly-check-selectors-and-extensions-via-requestpathinfo