0
votes

I've three html partials in my application and i'm creating an angular module using gulp template cache.

Html file names:

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

Gulp Task:

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'));
    });

After executing the above gulp task. It generates below angular module

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') is being generated for all 3 html's. But i need the actual file name instead of dropdown.html. Like below

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' +
    '');
     }]);

Please let me know how to do it.

1

1 Answers

0
votes

Strange, it works fine for me. You are using options that I don't see in the doc. Here is my task:

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