From 224d74c94f65ad3da871f1d0b82e313988f6e26e Mon Sep 17 00:00:00 2001 From: Dave Geddes Date: Thu, 15 May 2014 21:27:55 -0600 Subject: [PATCH 1/2] add append option for appending templates to a file --- tasks/angular-templates.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tasks/angular-templates.js b/tasks/angular-templates.js index 5dc75ca..3f7904f 100644 --- a/tasks/angular-templates.js +++ b/tasks/angular-templates.js @@ -10,6 +10,7 @@ var Compiler = require('./lib/compiler'); var Appender = require('./lib/appender'); +var fs = require('fs'); module.exports = function(grunt) { @@ -29,6 +30,7 @@ module.exports = function(grunt) { standalone: false, url: function(path) { return path; }, usemin: null, + append: false }); grunt.verbose.writeflags(options, 'Options'); @@ -47,8 +49,15 @@ module.exports = function(grunt) { compiled.push(compiler.compile(module, modules[module])); } - grunt.file.write(file.dest, compiled.join('\n')); - grunt.log.writeln('File ' + file.dest.cyan + ' created.'); + if (options.append){ + fs.appendFileSync(file.dest, compiled.join('\n')); + grunt.log.writeln('File ' + file.dest.cyan + ' updated.'); + } + else{ + grunt.file.write(file.dest, compiled.join('\n')); + grunt.log.writeln('File ' + file.dest.cyan + ' created.'); + } + if (options.usemin) { if (appender.save('generated', appender.concatUseminFiles(options.usemin, file))) { From bb5f6691d3793861492755d4713edc3c1b629cb4 Mon Sep 17 00:00:00 2001 From: Dave Geddes Date: Thu, 15 May 2014 21:49:14 -0600 Subject: [PATCH 2/2] update readme with append option --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 13ed574..79ccc86 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,13 @@ If you would like to prepend a comment, strip whitespace, or do post-processing on the HTML that `ngtemplates` doesn't otherwise do, use this function. +### append + +Normally grunt-angular-templates creates a new file at `dest`. +This option makes it append the compiled templates to the `dest` file rather than replace its contents. +This is just a useful alternative to creating a temporary `dest` file and concatting it to your application. + + ### standalone > Boolean indicated if the templates are part of an existing module or a standalone.