Need Clarification in data-sly-resource

Avatar

Avatar
Level 1
mudaliar847906
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
mudaliar847906
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
mudaliar847906
Level 1

01-10-2019

Hi Need to understand what is meaning of below line of code

<div data-sly-resource="${@path='FirstDivHeader', resourceType='foundation/components/parsys'}">

What is Used of @path in ablove example.

Replies

Avatar

Avatar
Contributor
Employee
hamidk92094312
Employee

Likes

103 likes

Total Posts

240 posts

Correct reply

38 solutions
Top badges earned
Contributor
Shape 1
Ignite 1
Give Back 50
Give Back 5
View profile

Avatar
Contributor
Employee
hamidk92094312
Employee

Likes

103 likes

Total Posts

240 posts

Correct reply

38 solutions
Top badges earned
Contributor
Shape 1
Ignite 1
Give Back 50
Give Back 5
View profile
hamidk92094312
Employee

01-10-2019

That is for manipulating the path of the resource. Please see the following document:

HTL Block Statements

Avatar

Avatar
Coach
Employee
jbrar
Employee

Likes

390 likes

Total Posts

869 posts

Correct reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Coach
Employee
jbrar
Employee

Likes

390 likes

Total Posts

869 posts

Correct reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile
jbrar
Employee

01-10-2019

As per my understanding, this means rendering a resource which is located at path FirstDivHeader and has a resourcetype of "foundation/components/parsys"

More details below:

data-sly-resource:

  • Includes a rendered resource.
  • Element: always shown.
  • Content of element: replaced with the content of the resource.
  • Attribute value: required; the path to include.
  • Attribute identifier: none.

Includes a rendered resource from the same server, using an absolute or relative path. An implementation should create a new request context when retrieving the output.

Note: this is comparable to a <jsp:include page="" />.

<section data-sly-resource="./path"></section>

With an expression more options can be specified:

<!--/* Following statements are equivalent: */--> 
<section data-sly-resource="./path"></section>
<section data-sly-resource="${'./path'}"></section

<!--
/* Manipulating the path: */-->

<section data-sly-resource="${'my/path' @ appendPath='appended/path'}"></section>
<section data-sly-resource="${'my/path' @ prependPath='prepended/path'}"></section

<!--
/* Manipulating selectors: */-->

<section data-sly-resource="${'my/path' @ selectors='selector1.selector2'}">
</section> <section data-sly-resource="${'my/path' @ selectors=['selector1', 'selector2']}">
</section> <section data-sly-resource="${'my/path' @ addSelectors='selector1.selector2'}">
</section> <section data-sly-resource="${'my/path' @ addSelectors=['selector1', 'selector2']}">
</section> <section data-sly-resource="${'my/path' @ removeSelectors='selector1.selector2'}"></section>
<section data-sly-resource="${'my/path' @ removeSelectors=['selector1', 'selector2']}"></section>
<section data-sly-resource="${'my/path' @ removeSelectors}"></section

<!--
/* Forcing the type of the rendered resource: */-->

<section data-sly-resource="${'./path' @ resourceType='my/resource/type'}"></section>

The scope of the data-sly-resource statement isn't passed to the template of the included resource.

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

587 likes

Total Posts

735 posts

Correct reply

246 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

587 likes

Total Posts

735 posts

Correct reply

246 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

01-10-2019

HI,

The use of "path" attribute in "data-sly-resource" :

When a component with the above snippet is included in a page, we would see a parsys being displayed and when we add any components within the parsys placeholder, behind the scene in the CRXDE, we would see the components available in the node hierarchy like below.

Let's say the page path is /content/xyx/abc.html

In CRXDE,  /content/xyx/abc/jcr:content/FirstDivHeader/componentname(that you would have included in that parsys)

In brief, it is part of the path with respect to the page where this snippet/component is being used.