I'm trying to integrate my code with JS.Packages a little better using James' recent blog post. One thing I'd like to do is use autoload() to manage namespace dependencies for me, since until now I've had to declare my namespaces at the top of each class file to make sure the objects were defined.I have it working when I change my filenames to all lowercase with underscores matching camelcase class names, but really I'd like to keep my existing naming stucture, which is camelcase for folders, filenames, and class names. They all match. Is there a way to use autoload like this?
I'm trying to integrate my code with JS.Packages a little better using James' recent blog post. One thing I'd like to do is use autoload() to manage namespace dependencies for me, since until now I've had to declare my namespaces at the top of each class file to make sure the objects were defined.I have it working when I change my filenames to all lowercase with underscores matching camelcase class names, but really I'd like to keep my existing naming stucture, which is camelcase for folders, filenames, and class names. They all match. Is there a way to use autoload like this?
So do you structure all of your projects with lowercase-underscore paths? Or more bluntly, if I want to use autoload right now am I pretty much locked into that structure?
One more question here - I have a class named UIComponent. Should the filename be u_i_component.js for this scheme to work? Should I rename it to UiComponent so I can have the filename be ui_component.js?
I have refactored all my names to match what we've been discussing.
I'm trying to fire everything up again, but the namespace dependencies aren't working. I have a little confusion about mixing autoload() with regular file() calls. Right now at the top of my manifest I have two autoload lines:
autoload(/^(.*)\.[^\.]+$/, {from: CONTEXT_PATH + '/scripts', require: '$1'});
autoload(/^(.*)$/, {from: CONTEXT_PATH + '/scripts'});
So I tried requiring one of my classes, which has 1 dependency. That dependency (it's called MyApp.util.Utils) fails to execute because MyApp is not defined.
Can you give me a little shove in the right direction?
Hey, I am having trouble getting Git set up on this machine. Can I just email it to you?
I'm trying to fire everything up again, but the namespace dependencies aren't working. I have a little confusion about mixing autoload() with regular file() calls. Right now at the top of my manifest I have two autoload lines:
autoload(/^(.*)\.[^\.]+$/, {from: CONTEXT_PATH + '/scripts', require: '$1'});
autoload(/^(.*)$/, {from: CONTEXT_PATH + '/scripts'});
Instead (and this might be undocumented, aside from my blog post) you can do this:pkg('MyApp.util.Utils').requires('JS.Module');pkg('MyApp.ui.UIComponent').requires('MyApp.util.Utils');
I can see this shrinking my huge manifest to just a handful of lines.