2015-05-07 31 views
0

我在我的应用程序中有三个html partials,我正在使用gulp模板缓存创建一个角度模块。gulp-angular-templatecache - 合并多个html部分

HTML文件名:

  1. dropdown.html
  2. 下拉-select.html
  3. 下拉-multiselect.html

咕嘟咕嘟任务:

gulp.task('dropdown', function() 
    { 
     return gulp.src('modules/dropdown/*.html') 
      .pipe(plugins.plumber()) 
      .pipe(plugins.templatecache({ 
       output: 'dropdown_template.js', 
       moduleName: 'dropdown', 
       prepend: 'dropdown.html', // Need to replace with actual file name's 
       strip: 'views/' 
      })) 
      .pipe(gulp.dest('build/js/templates')); 
    }); 

后执行上述吞咽任务。它产生下面的角模块

angular.module("dropdown").run(['$templateCache', function(a) { a.put('dropdown.html', '<div class="dropdown" ng-transclude="parent"></div>\n' + 
    ''); // 1st html 
    a.put('dropdown.html', '<div ng-transclude="1"></div>\n' + 
    ''); //2nd html - name is wrong it should be dropdown-select.html 
    a.put('dropdown.html', '<div class="dropdown-menu dropdown-menu--{{ position }}">\n' + 
    '');// 3rd html - name is wrong it should be dropdown-multiselect.html 
    }]); 

a.put( 'dropdown.html')被用于所有3层HTML的生成。但我需要实际的文件名而不是dropdown.html。像下面一样

angular.module("dropdown").run(['$templateCache', function(a) { a.put('dropdown.html', '<div class="dropdown" ng-transclude="parent"></div>\n' + 
    ''); 
    a.put('dropdown-select.html', '<div ng-transclude="1"></div>\n' + 
    ''); 
    a.put('dropdown-multiselect.html', '<div class="dropdown-menu dropdown-menu--{{ position }}">\n' + 
    ''); 
    }]); 

请让我知道如何去做。

回答

0

奇怪的是,它适用于我。您正在使用我在doc中未看到的选项。这是我的任务:

gulp.task('build-templatecache', function() { 
    return gulp.src(config.srcPartials) 
    .pipe(renameRegex(/\/partials/, '')) 
    .pipe(templatecache({ 
     root: 'partials', 
     module: 'game', 
     })) 
    .pipe(gulp.dest(config.destPartials)); 
});