Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Dynamically Update Path On data-sly-use

Avatar

Level 5

Hi,

I am calling one template using data-sly-use. below is the directory structure i have

/apps/myprj1/core/components/content/componentA/componentA.html

/apps/myprj1/core/components/content/templates/templatesA.html

Now I want to use the template in componentA.html as below. But not able to call template.

<sly data-sly-use.myTemplate="templates/templatesA.html"

     data-sly-call=""/>

Idea is during using template, avoid the project name in the path i.e. myprj1

How this can be fix.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hello,

It doesn't work because the path to the template isn't quite right You use a linux-style relative directory path to point to your templates. In your case, if you are trying to access:

/apps/myprj1/core/components/content/templates/templatesA.html

from

/apps/myprj1/core/components/content/componentA/componentA.html

Then the relative path is:

../templates/templatesA.html

Try using that instead

I reproduced it on my instance using this fix:

1846967_pastedImage_4.png

Peek 2019-10-22 21-44.gif

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hello,

It doesn't work because the path to the template isn't quite right You use a linux-style relative directory path to point to your templates. In your case, if you are trying to access:

/apps/myprj1/core/components/content/templates/templatesA.html

from

/apps/myprj1/core/components/content/componentA/componentA.html

Then the relative path is:

../templates/templatesA.html

Try using that instead

I reproduced it on my instance using this fix:

1846967_pastedImage_4.png

Peek 2019-10-22 21-44.gif