-
27 Nov 2012 4:46 PM #1
Unanswered: requiring a file with . in the filename
Unanswered: requiring a file with . in the filename
This is actually being used with Siesta's requireOK method, but since it's based on Ext.require(), I thought I'd ask here too. I saw the docuementation on how to load dependencies in your informative article (http://docs.sencha.com/touch/2-0/#!/...c_dependencies), but I have a question I didn't see an answer to there.
How would I require a file that had . in the filename? For example, if I have a local extension MyApp/extensions/Ext.form.field.Text.js, and I try to require:
The file will look for a Text.js file in the pathCode:Ext.require([ 'MyApp.extensions.Ext.form.field.Text' ]);
MyApp/extensions/Ext/form/field/Text.js.
instead of
MyApp/extensions/Ext.form.field.Text.js
How do I tell it to ignore . in file names?
-
28 Nov 2012 3:24 AM #2
I don't know if that's really possible, checkout Loader.js getPath method:
where dotRe = /\./gCode:getPath: function(className) { var path = '', paths = Loader.config.paths, prefix = Loader.getPrefix(className); if (prefix.length > 0) { if (prefix === className) { return paths[prefix]; } path = paths[prefix]; className = className.substring(prefix.length + 1); } if (path.length > 0) { path += '/'; } return path.replace(slashDotSlashRe, '/') + className.replace(dotRe, "/") + '.js'; },
So as a small example I tried this:"Ext.a.b.c.d".replace(/\./g, "/") + '.js';And returned
"Ext/a/b/c/d.js"You could try to override this method so the return does not replace the className...
Good luck


Reply With Quote