Replace A Block Of Html With Another Block Of Html Using Grunt
I have a block of html something like this -
Solution 1:
Try to use grunt-string-replace, you can do something like this:
'string-replace': {
logo: {
files: [{
src:'path/to/file.html',
dest:'path/to/file.html'
}],
options: {
replacements: [{
pattern:'<img src = "logo.png">',
replacement:'{{logo}}'
}]
}
}
}
Don't forget to loadNpmTask and run it like:
grunt.loadNpmTasks('grunt-string-replace');
grunt.registerTask('replace', ['string-replace:logo']);
Reminder, according to the 'grunt-string-replace' docs:
Replaces strings on files by using string or regex patterns (...) grunt-string-replace is basically a wrapper of String.prototype.replace you can also provide a function as a replacement pattern instead of a string or a template.
Post a Comment for "Replace A Block Of Html With Another Block Of Html Using Grunt"