Please see my compile-jade task below.
'use strict';
var path = require('path');
module.exports = function(gulp, plugins, config, browserSync) {
return function() {
var jadeParams = {
pretty: true,
compileDebug: true
};
gulp.src(config.templatesSource, { base: './src' })
.pipe(plugins.data(function(file) {
try {
return require( path.resolve( '.', config.dataFile ) );
} catch (e) {
return plugins.util.log(plugins.util.colors.magenta('jade error'), e);
}
}))
.pipe(plugins.jade(jadeParams))
.pipe(gulp.dest(config.outputDistDir))
.pipe(browserSync.stream());
};
};
Everything will work fine without any syntax error (including the data being passed).