Dynamically Update Path On data-sly-use

vdhim23

22-10-2019

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.

Accepted Solutions (1)

Accepted Solutions (1)

Theo_Pendle

MVP

22-10-2019

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

Answers (0)