Expand my Community achievements bar.

SOLVED

data-sly-resource attributes

Avatar

Level 4

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).
1 Accepted Solution

Avatar

Correct answer by
Employee

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

View solution in original post

5 Replies

Avatar

Level 4

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.

Avatar

Level 1

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

Avatar

Correct answer by
Employee

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

Avatar

Level 4

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