html2js stripPrefix基于用户的正则表达式

Lui*_*lim 2 regex angularjs ng-html2js

我正在尝试使用ng-html2js来填充我的$ templateCache来运行一些单元测试.

问题是,我的模板位于不同的项目上,我使用它们的相对路径:

 preprocessors: {
        '..//project2//Content//Templates/**/*.html': ['ng-html2js']
    },
Run Code Online (Sandbox Code Playgroud)

它将缓存条目存储为:

"C:\用户\用户\文件\ GitHub的\ solutiondir \项目2 \内容\模板\"

题:

是否有任何stripPrefix值可用于删除整个:

C:\ Users\user\Documents\GitHub\solutiondir\project2 \,无论用户名如何都可以使用?

它可能基本上是找出正确的正则表达式,因为预处理器的代码是这样的:

    var log = logger.create('preprocessor.html2js');
  var moduleName = config.moduleName;
  var stripPrefix = new RegExp('^' + (config.stripPrefix || ''));
  var prependPrefix = config.prependPrefix || '';
  var stripSufix = new RegExp((config.stripSufix || '') + '$');
  var cacheIdFromPath = config && config.cacheIdFromPath || function(filepath) {
    return prependPrefix + filepath.replace(stripPrefix, '').replace(stripSufix, '');
  };
Run Code Online (Sandbox Code Playgroud)

Lui*_*lim 5

好吧,想通了这里:

 ngHtml2JsPreprocessor: {
        // If your build process changes the path to your TEMPLATES,
        // use stripPrefix and prependPrefix to adjust it.
        stripPrefix: "(.*)project2",


    },
Run Code Online (Sandbox Code Playgroud)