grunt-text-replace icon indicating copy to clipboard operation
grunt-text-replace copied to clipboard

Added support for destination to be a function

Open ahmednuaman opened this issue 10 years ago • 1 comments

So I needed the ability to also change the filename of the replaced files, so I added the ability to specify destination as a function, for example:

replace: {
  all: {
    src: ['foo.json', 'bar/*.json'],
    dest: function (input) {
      return input + '.j2';
    },
    replacements: [{
      from: 'foo',
      to: 'bar'
    }]
  }
}

Hope that's cool :)

ahmednuaman avatar Jun 09 '15 12:06 ahmednuaman

Thanks for this pull request. It is very useful for me for a quick and dirty templating mechanism.

This will replace the texts from files containing .template to the corresponding file without .template For example It will replace the texts from foo.template.css to foo.css or blah.template.js to blah.js

src: ['app/assets/**/*.template.*'],
dest: function (input) {
  return input.replace('.template', '');
},
replacements: [{
      from: 'foo',
      to: 'bar'
}]

leszekhanusz avatar Feb 28 '18 11:02 leszekhanusz