Skip to content

Added support for destination to be a function#42

Open
ahmednuaman wants to merge 1 commit intoyoniholmes:masterfrom
ahmednuaman:master
Open

Added support for destination to be a function#42
ahmednuaman wants to merge 1 commit intoyoniholmes:masterfrom
ahmednuaman:master

Conversation

@ahmednuaman
Copy link
Copy Markdown

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 :)

@leszekhanusz
Copy link
Copy Markdown

leszekhanusz commented Feb 28, 2018

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'
}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants