Skip to content

Instantly share code, notes, and snippets.

@tristola
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tristola/07a8e8d72cd633f79867 to your computer and use it in GitHub Desktop.
Save tristola/07a8e8d72cd633f79867 to your computer and use it in GitHub Desktop.
simple web project with templating
var gulp = require('gulp');
var data = require('gulp-data');
var path = require('path');
var jade = require('gulp-jade');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
gulp.task('default',['jade','browser-sync'], function () {
gulp.watch("templates/*.jade", ['jade']);
});
// Using templates with data from data folder
gulp.task('jade', function() {
gulp.src('./templates/*.jade')
.pipe(data(function(file) {
return require('./data/' + path.basename(file.path) + '.json');
}))
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('public/'))
.pipe(browserSync.reload({stream: true}));
});
// Static server
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./public"
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment