You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Robert Munteanu <ro...@apache.org> on 2015/02/04 12:47:11 UTC
Replacing resolver.getResource() with sling:include
Hi,
I have a ResourceResolver.getResource call which I would like to replace
with a <sling:include /> .
What I currently have
Resource configResource =
resolver.getResource("my/component/config.js.jsp");
<cq:include script="<%=configResource.getPath()%>" />
What I want to have
<sling:include resource="<%= resource %>"
resourceType="my/component" replaceSelectors="config" />
The problem here is that I need the extension to be set as well ( the
original request's extension is set to .html ).
A brief test done by creating a resource with sling:resourceType
"my/component" at /content/test revealed that
- /content/test.config.js returns the right content
- /content/test.config.html does not
So my questions are:
1. Is there a way I can convince sling:include to include the extension?
2. Is there isn't, is this a valid enhancement request?
Thanks,
Robert
Re: Replacing resolver.getResource() with sling:include
Posted by Robert Munteanu <ro...@apache.org>.
Hi Julian,
On Wed, Feb 4, 2015 at 1:51 PM, Julian Sedding <js...@gmail.com> wrote:
> Hi Robert
>
> You could always do the following:
>
> <sling:include path="<%= resource.getPath() %>.config.js"
> resourceType="my/component"/>
That works, thank you!
Robert
>
> Regards
> Julian
>
>
> On Wed, Feb 4, 2015 at 12:47 PM, Robert Munteanu <ro...@apache.org> wrote:
>> Hi,
>>
>> I have a ResourceResolver.getResource call which I would like to replace
>> with a <sling:include /> .
>>
>> What I currently have
>>
>> Resource configResource =
>> resolver.getResource("my/component/config.js.jsp");
>> <cq:include script="<%=configResource.getPath()%>" />
>>
>> What I want to have
>>
>> <sling:include resource="<%= resource %>"
>> resourceType="my/component" replaceSelectors="config" />
>>
>> The problem here is that I need the extension to be set as well ( the
>> original request's extension is set to .html ).
>>
>> A brief test done by creating a resource with sling:resourceType
>> "my/component" at /content/test revealed that
>>
>> - /content/test.config.js returns the right content
>> - /content/test.config.html does not
>>
>> So my questions are:
>>
>> 1. Is there a way I can convince sling:include to include the extension?
>> 2. Is there isn't, is this a valid enhancement request?
>>
>> Thanks,
>>
>> Robert
>>
Re: Replacing resolver.getResource() with sling:include
Posted by Julian Sedding <js...@gmail.com>.
Hi Robert
You could always do the following:
<sling:include path="<%= resource.getPath() %>.config.js"
resourceType="my/component"/>
Regards
Julian
On Wed, Feb 4, 2015 at 12:47 PM, Robert Munteanu <ro...@apache.org> wrote:
> Hi,
>
> I have a ResourceResolver.getResource call which I would like to replace
> with a <sling:include /> .
>
> What I currently have
>
> Resource configResource =
> resolver.getResource("my/component/config.js.jsp");
> <cq:include script="<%=configResource.getPath()%>" />
>
> What I want to have
>
> <sling:include resource="<%= resource %>"
> resourceType="my/component" replaceSelectors="config" />
>
> The problem here is that I need the extension to be set as well ( the
> original request's extension is set to .html ).
>
> A brief test done by creating a resource with sling:resourceType
> "my/component" at /content/test revealed that
>
> - /content/test.config.js returns the right content
> - /content/test.config.html does not
>
> So my questions are:
>
> 1. Is there a way I can convince sling:include to include the extension?
> 2. Is there isn't, is this a valid enhancement request?
>
> Thanks,
>
> Robert
>