Skip to content

Commit

Permalink
Merge pull request #3 from DaftMonk/feature-clean-injection
Browse files Browse the repository at this point in the history
Clear existing content between start/end tags before injection
  • Loading branch information
joakimbeng committed Jul 3, 2014
2 parents 7604bb1 + f3cd1a7 commit 7ff1274
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tasks/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ module.exports = function(grunt) {
}
});

// Clear existing content between injectors
var templateContent = options.templateString || grunt.file.read(template),
templateOriginal = templateContent;

var re = getInjectorTagsRegExp(options.starttag, options.endtag);
templateContent = templateContent.replace(re, function (match, indent, starttag, content, endtag) {
return indent + starttag + '\n' + indent + endtag;
});

if (templateContent !== templateOriginal || !grunt.file.exists(destination)) {
grunt.file.write(destination, templateContent);
}
});

/**
Expand Down

0 comments on commit 7ff1274

Please sign in to comment.