hi josh, If you are talking about reusable js functions I recently stored my .ecma file in the repo and built a little wrapper that would eval() my file...
But I completely agree that we need a facility in sling that does that and in addition to that i also think we need a dynamic script include of an esp (or JSP) script respecting the resourcetype hierarchies. Regards, David On 9/26/08, Joshua Oransky <[EMAIL PROTECTED]> wrote: > This is an issue because I have several functions that I need to use > all over, and the current resource include is insufficient. Right now, > as I see it, I need to create redundant code in every script where I > want to be able to use my functions... instead of just being able to > include a script that has them all... > > Or am I mistaken? How can I create reusable code snippets? > > Thanks, Josh > > On Sep 17, 2008, at 12:59 PM, Tobias Bocanegra wrote: > >> hi josh, >> one solution is to use another selector or resource type for your >> included script. >> >> eg: >> /page >> page.jsp >> content.jsp >> >> and in page.jsp you do: >> <sling:include forceSelector="content" /> >> this will select the content.jsp as script when including 'this' >> resource. the draw back of this is, that you 'destroy' any selectors >> from the request, i.e. you can't propagate them into your content.jsp >> without some manual magic. >> >> another solution is using another resource type. eg: >> >> /page >> page.jsp >> /content >> content.jsp >> >> and in page.jsp you do: >> >> <sling:include resourceType="page/content" /> >> >> you could even make this work 'relative' eg: >> >> String rt = resource.getResourceType() + "/content"; >> <sling:include resourceType="<%= rt =>" /> >> >> regards, toby >> >> ps: i wrote an extended include tag that allows direct execution of >> other scripts without having an extra 'include'. this is somewhat >> contradictory to the sling philosophy that tries to hide the >> script-resolution-magic from the user by the paradigm that only >> 'resources' are included. imo, in some cases, you really know what you >> do, and you want to execute/include a designated script. >> >> >> >> On 9/17/08, Joshua Oransky <[EMAIL PROTECTED]> wrote: >>> Hello, >>> >>> How can I statically include code from another script? That >>> is, >>> include it into execution in the context of the currentNode. >>> Sling.include >>> does not work for me, because it executes in the context of the >>> included >>> node. I have several instances where I need to reuse code in >>> different >>> visual layouts. It seems inefficient to write the same code over >>> and over, >>> and is a maintenance nightmare. I know there's the >>> sling:superResourceType, >>> but that doesn't really solve my issue, as I want to have reusable >>> snippets. >>> >>> Thanks - Josh >>> > > -- Visit: http://dev.day.com/ - Day JCR Cup 08 - Win a MacBook Pro
