【问题标题】:gulp-angular-templatecache - combine multiple html partialsgulp-angular-templatecache - 组合多个 html 部分
【发布时间】:2015-05-18 05:41:34
【问题描述】:

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

HTML 文件名:

  1. dropdown.html
  2. 下拉选择.html
  3. 下拉多选.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.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' +
    '');
     }]);

请告诉我怎么做。

【问题讨论】:

    标签: angularjs gulp


    【解决方案1】:

    奇怪,它对我来说很好用。您正在使用我在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));
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-13
      相关资源
      最近更新 更多