Skip to content

Instantly share code, notes, and snippets.

@zrobit
Created January 7, 2016 01:52
Show Gist options
  • Select an option

  • Save zrobit/f4acd9051939fc4bc9c4 to your computer and use it in GitHub Desktop.

Select an option

Save zrobit/f4acd9051939fc4bc9c4 to your computer and use it in GitHub Desktop.
receta para para compilar jade sin el plugin gulp-jade
var gulp = require('gulp'),
jade = require('jade'),
through = require('through2');
var templates = function(){
var render = function(){
function compile(file, enc, cb){
var compiled;
var contents = String(file.contents);
//aqui va tu data pero podrías cargarlo desde un archivo con require
var locals = {}
//aqui las config jade
var options = {pretty:true, filename: file.path};
file.path = file.path.substr(0, file.path.lastIndexOf(".")) + ".html";
compiled = jade.compile(contents, options)(locals);
file.contents = new Buffer(compiled);
cb(null, file);
}
return through.obj(compile);
};
return gulp.src(['templates/**/*.jade'])
.pipe(render())
.pipe(gulp.dest(config.templates.dest));
};
gulp.task('templates', templates);
@zrobit
Copy link
Copy Markdown
Author

zrobit commented Jan 7, 2016

Una de las razones de compilar jade de esta forma sin necesidad de plugin, es por que puedes hacerlo con la ultima versión de la librería Jade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment