The approach mentioned by Carsten has two drawbacks:
* it changes the selectors seen by any scripts included further down
the include stack (IIRC this was the reason why <sling:call/> was
introduced in the first place)
* resourceResolution has to be done again, even though we know we want
to render the same resource (maybe <sling:include
resource="${resource}"/> also prevents this, I didn't check)

I created SLING-3874[0] with a proof-of-concept implementation for a
<sling:partial/> tag. This allows selecting another rendering script
for the current resource with the specified selector. Downstream
includes are not affected by this, however.

Example page.jsp (see Gabriel's example above):
<html>
    <sling:partial selectors="head"/>
    <sling:partial selectors="body"/>
</html>

Regards
Julian

[0] https://issues.apache.org/jira/browse/SLING-3874

On Fri, Aug 22, 2014 at 12:11 PM, Gabriel Walt <gw...@adobe.com> wrote:
>
> Wow, couldn't believe this was working, very nice!! :)
>
> Thanks!
>
>
> On 22/08/14 11:17, "Carsten Ziegeler" <cziege...@apache.org> wrote:
>
>>You can simply use sling:include instead, add a selector and your script
>>act on that specific selector - that's language independent.
>>
>>Carsten
>>
>>
>>2014-08-22 10:50 GMT+02:00 Gabriel Walt <gw...@adobe.com>:
>>
>>>
>>> Thanks for your answers! Let me try to provide more context and be more
>>> specific.
>>>
>>> With sling:resourceSuperType (or with /apps /libs overlaying), you can
>>> customize any script of your component. A common practice is to split
>>> large script templates into partials that can then each be independently
>>> customized, to avoid full script duplication, and to adapt only parts
>>> of it.
>>>
>>> The typical example is a page component that can for instance end up
>>>with
>>> a structure like:
>>> - page.jsp
>>>     - head.jsp
>>>         - headlibs.jsp
>>>    - body.jsp
>>>         - top.jsp
>>>         - content.jsp
>>>         - bottom.jsp
>>>         - bodylibs.jsp
>>>
>>> These scripts are usually all included with something like a sling:call,
>>> but then this makes it impossible in an extending component to use a
>>> different script language than the one used in the super-type (so in our
>>> example we'd be forced to go with JSP, and couldn't use ESP, Sightly,
>>>etc).
>>>
>>> Thus, it would be nice to be able to do an include of script partials
>>>that
>>> are not binding to a particular script language, like for instance:
>>>     <sling:call script="myscript.*" />
>>> instead of:
>>>     <sling:call script="myscript.jsp" />
>>>
>>> Best,
>>> Gabriel
>>>
>>>
>>>
>>
>>
>>--
>>Carsten Ziegeler
>>Adobe Research Switzerland
>>cziege...@apache.org
>

Reply via email to