我的应用程序中有三个html部分,我正在使用gulp模板缓存创建一个角度模块。
Html文件名:
Gulp任务:
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'));
});
执行上述gulp任务后。它生成以下角度模块
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.gput(&#39; dropdown.html &#39;)正在为所有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 :(得分: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));
});