1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    33
    Answers
    2
    Vote Rating
    0
    alane is on a distinguished road

      0  

    Default 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:
    Code:
    Ext.require([     'MyApp.extensions.Ext.form.field.Text' ]);
    The file will look for a Text.js file in the path
    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?

  2. #2
    Sencha User
    Join Date
    Oct 2009
    Posts
    95
    Answers
    3
    Vote Rating
    2
    Albareto is on a distinguished road

      0  

    Default


    I don't know if that's really possible, checkout Loader.js getPath method:

    Code:
    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';
            },
    where dotRe = /\./g

    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

Thread Participants: 1

Tags for this Thread