Skip to content

Commit

Permalink
Merge pull request #89 from geddski/master
Browse files Browse the repository at this point in the history
add append option
  • Loading branch information
ericclemmons committed May 16, 2014
2 parents ffde78e + bb5f669 commit 5892857
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions tasks/angular-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

var Compiler = require('./lib/compiler');
var Appender = require('./lib/appender');
var fs = require('fs');

module.exports = function(grunt) {

Expand All @@ -29,6 +30,7 @@ module.exports = function(grunt) {
standalone: false,
url: function(path) { return path; },
usemin: null,
append: false
});

grunt.verbose.writeflags(options, 'Options');
Expand All @@ -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))) {
Expand Down

0 comments on commit 5892857

Please sign in to comment.