Created
January 7, 2016 01:52
-
-
Save zrobit/f4acd9051939fc4bc9c4 to your computer and use it in GitHub Desktop.
receta para para compilar jade sin el plugin gulp-jade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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