I have the following gulp task that is currently not working.
gulp.task('emails', function() {
  gulp.src('views/emails/src/**/*.html')
    .pipe(inky())
    .pipe(gulp.dest('views/emails/dist/'+debug()+"/html.ejs"));
});
I would like to iterate over the /views/emails/src/ directory, find all html files, then use inky to convert them to html, and then copy the resulting html file to...
views/emails/dist/'+ folderName +"/html.ejs
where folderName is the name of the .html file that was processed.
I need this in order to get the file structure in the format that the npm email-templates package requires.
That's a job for gulp-rename:
var rename = require('gulp-rename');
var path = require('path');
gulp.task('emails', function() {
  gulp.src('views/emails/src/**/*.html')
    .pipe(inky())
    .pipe(rename(function(file) {
      file.dirname = path.join(file.dirname, file.basename);
      file.basename = 'html';
      file.extname = '.ejs';
    }))
    .pipe(gulp.dest('views/emails/dist/'));
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With