Skip to content

Instantly share code, notes, and snippets.

@TorbenKoehn
Created October 28, 2016 10:27
Show Gist options
  • Save TorbenKoehn/23aeae26002480333bf6b3c560af7100 to your computer and use it in GitHub Desktop.
Save TorbenKoehn/23aeae26002480333bf6b3c560af7100 to your computer and use it in GitHub Desktop.
An example gulpfile.js to use Tale Jade with WordPress (or similar template engines)
var gulp = require('gulp'),
exec = require('gulp-exec');
var templateFiles = [
'wp-content/themes/my-theme/index.jade',
'wp-content/themes/my-theme/page.jade',
'wp-content/themes/my-theme/page-single.jade',
'wp-content/themes/my-theme/archive.jade',
//All other template files
//Make sure they reside at the exact same positions where the wordpress files would be
],
compilerCommand = 'tale-jade';
gulp.task('build', function(done) {
var doneCount = 0;
templateFiles.forEach(function (path) {
//Put together the command to run (e.g `tale-jade compile whatever.jade whatever.php`)
var command = compilerCommand + ' compile ' + path + ' ' + path.slice(0, -4) + '.php';
//Run the command asynchronously
exec(command, function (err, stdout, stderr) {
//Log stuff
console.log(stdout);
console.log(stderr);
//Count to tell gulp when we finished (via done())
doneCount++;
if (doneCount === templateFiles.length)
done();
});
});
});
gulp.task('watch', function() {
gulp.watch(['wp-content/themes/**/*.jade'], ['build']);
});
gulp.task('default', ['watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment