cgross / grunt-dom-munger

Grunt task to read and manipulate HTML with CSS selectors.
MIT License
93 stars 40 forks source link

Write to file the return of a callback? #13

Closed allanhortle closed 10 years ago

allanhortle commented 10 years ago

I'm not sure if you can't cant do this or the documentation is just unclear. Basically what i want to do is to use the callback to select one dom object in the html and then write that to the destination file.

cgross commented 10 years ago

Hmm. Seems I missed this issue when you first logged it. Yes you can definitely do that but you'll have to simply write the appropriate node code in the callback. Something like:

callback: function($){
  var html = $.html('your_selector');
  var fs = require('fs');
  fs.writeFileSync('myDestinationFile.html',html);
}