forked from gulp-community/gulp-pug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (24 loc) · 835 Bytes
/
index.js
File metadata and controls
29 lines (24 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var es = require('event-stream');
var compile = require('jade').compile;
var clone = require('clone');
var ext = require('gulp-util').replaceExtension;
module.exports = function(options){
'use strict';
var opts = options ? clone(options) : {};
function jade(file, callback){
var newFile = clone(file);
opts.filename = file.path;
var compiled = compile(String(newFile.contents), opts);
if(opts.client){
newFile.path = ext(newFile.path, '.js');
newFile.shortened = ext(newFile.shortened, '.js');
newFile.contents = new Buffer(compiled.toString());
} else {
newFile.path = ext(newFile.path, '.html');
newFile.shortened = ext(newFile.shortened, '.html');
newFile.contents = new Buffer(compiled(opts.data));
}
callback(null, newFile);
}
return es.map(jade);
};