Beispiel #1
0
gulp.task('templates', function() {
	return gulp.src('app/**/*.pug')
		.pipe(gulpif(global.isWatching, cached('pug')))
		.pipe(inheritance({basedir: 'app'}))
		.pipe(filter(function (file) {return /app[\\\/]pages/.test(file.path);}))
		.pipe(data(function(file) {
			return {
				'data': JSON.parse(fs.readFileSync('app/data.json')),
			};
		}))
		.pipe(pug({pretty: '\t'}))
		.pipe(rename({dirname: '.'}))
		.pipe(gulp.dest('dist'));
});
Beispiel #2
0
 return new Task('pug_' + (pug_task_increment++), function ()
 {
     return Gulp
         .src(gulp_src)
         .pipe(Plumber())
         .pipe(Changed(options.dest, {extension: extension}))
         .pipe(PugInheritance({basedir: options.src, extension: options.pugExtension, skip: 'node_modules'}))
         .pipe(Ignore.exclude(options.exclude))
         .pipe(Pug(pug_options))
         .pipe(Rename(function (path)
         {
             path.extname = extension;
         }))
         .pipe(Gulp.dest(options.dest))
 }).watch(watch);
gulp.task('jade', function() {
    return gulp.src('app/**/*.pug')

        .pipe(
          plumber( function(error) {
            gutil.log(error.message);
            this.emit('end');
          })
        )

        //only pass unchanged *main* files and *all* the partials
        .pipe(changed('dist', {extension: '.html'}))

        //filter out unchanged partials, but it only works when watching
        .pipe(gulpif(global.isWatching, cached('jade')))

        .pipe(debug({title: 'debug-before'}))

        //find files that depend on the files that have changed
        .pipe(pugInheritance({basedir: 'app', extension: '.pug', skip:'node_modules'}))

        .pipe(debug({title: 'debug-after'}))

        //filter out partials (folders and files starting with "_" )
        .pipe(filter(function (file) {
            return !/\/_/.test(file.path) && !/^_/.test(file.relative);
        }))

        .pipe(debug({title: 'debug-after-filter'}))
        //process jade templates
        .pipe(jade())

        //save all the files
        .pipe(gulp.dest('dist'))
        .pipe(notify({message: 'Served "<%= file.path %>"'}));
});