My current challenge involves generating templatecache using gulp-angular-templatecache
and merging it with an Angular script into a single JS file.
Here is the gulp task setup:
gulp.task('generatetemplatecache', function () {
return gulp.src(['dev/app/**/*.tpl.html'])
.pipe(minifyHTML({quotes: true}))
.pipe(templateCache({ module:'templateCache', standalone:true }))
.pipe(gulp.dest('public/app'));
});
This is a snippet of how the output appears:
var app = angular.module("app",['templateCache']);
angular.module("templateCache", []).run(["$templateCache", function($templateCache) {$templateCache.put("test.tpl.html","<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>My Title</title></head><body></body></html>");
$templateCache.put("layout/popover.tpl.html","<h3 class=\"popover-title\">Click</h3><div class=\"popover-content\"><table style=\"width:600px\" class=\"table\"><tr ng-repeat=\"customer in customers\"><td>{{customer.name}}</td><td>{{customer.street}}</td></tr></table>ss</div>");
Despite the setup, I've encountered an issue where Angular does not load from the templatecache. Instead, it always retrieves the original template HTML file. This poses a problem when the HTML file is unavailable, causing display issues.
Why is this not working as expected? Could there be a mistake in my approach? Is the URL in the template cache relative to the index.html
or the root domain?