[ 6 posts ]

Stephen Woods

YUI Contributor

  • Username: saw
  • Joined: Wed Jul 08, 2009 2:28 pm
  • Posts: 8
  • Location: San Francisco, CA
  • Twitter: ysaw
  • GitHub: saw
  • Gists: saw
  • Offline
  • Profile

Multiple Filters for loader

Post Posted: Wed Mar 28, 2012 10:51 am
+0-
We are using a custom url compression scheme to keep are combo urls short. I would like to be able to use the same scheme on the yui component urls. My first thought was using the "filter" param on the loader config, but this is quite limited. Aside from a patch, does anyone have a better idea?

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Multiple Filters for loader

Post Posted: Mon Apr 02, 2012 7:21 am
+0-
This would require changes to the YUI combo service, not just Y.Loader.

Stephen Woods

YUI Contributor

  • Username: saw
  • Joined: Wed Jul 08, 2009 2:28 pm
  • Posts: 8
  • Location: San Francisco, CA
  • Twitter: ysaw
  • GitHub: saw
  • Gists: saw
  • Offline
  • Profile

Re: Multiple Filters for loader

Post Posted: Tue Apr 03, 2012 8:27 am
+0-
We host our own combo handler.

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Multiple Filters for loader

Post Posted: Tue Apr 03, 2012 8:58 am
+0-
I think you'll still need to patch the loader. In principle, configFn (undocumented, but search the source) might be able to handle it, but I'm not sure if you can modify the configFn for core YUI components without patching.

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile

Re: Multiple Filters for loader

Post Posted: Tue Apr 03, 2012 10:47 am
+0-
In 3.5.0, you should be able to hijack the resolve method and bypass it that way.

(One of the many, many reasons I put it there)

:)

Dylan Oudyk

YUI Contributor

  • Offline
  • Profile

Re: Multiple Filters for loader

Post Posted: Tue Apr 03, 2012 11:02 am
+0-
I think you might be able to get by without any patching. I hope I'm not too behind, I haven't used YUI since 3.2.0 but try this out, it's worth a shot at least.

The filter config is like as follows:
Code:
filter : {
   searchExp : ".+", //match the entire url string
   replaceStr : 'replacement'
}


Here's the thing though in JavaScript, string.replace takes a regex and a string to replace the pattern with but instead of a string you can alternatively pass in a function. Yeah that's right, a function.

What I ended up doing was use this regex ".+" which will match anything.

Then for replaceStr put in a function like:
Code:
filter : {
   searchExp: '.+' //match entire string
   , replaceStr : function (theEntirePath){
             console.log(theEntirePath);  //so you know what you're working with
             var myNewPath = '';

             //your awesome string processing code here
             //...
             //...
             return myNewPath;
    }
}


Like I mentioned this worked as of version 3.2.0 (I'm behind I know) and I'm aware Dav is doing some rework on loader but hopefully this functionality isn't removed. If so then when I get back to porting again I'm in the same boat you are.

Let me know how it goes please and good luck.
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum