From 101dd4add48326da51bbc6814996489aa7c68266 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Tue, 20 Oct 2015 15:02:41 +0900 Subject: [PATCH] pass filename option to jade.compileClient --- index.coffee | 3 ++- index.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.coffee b/index.coffee index 816c94a..5590f86 100644 --- a/index.coffee +++ b/index.coffee @@ -2,12 +2,13 @@ jade = require 'react-jade' through = require 'through2' replaceExt = require 'replace-ext' -module.exports = (opt) -> +module.exports = (opt = {}) -> stream = through.obj (file, enc, callback) -> if file.isNull() @push(file) return callback() else if file.isBuffer() + opt['filename'] = file.path templateString = jade.compileClient(file.contents.toString(), opt).toString() file.contents = new Buffer 'module.exports = ' + templateString file.path = replaceExt(file.path, '.js') diff --git a/index.js b/index.js index fae7e01..7689582 100644 --- a/index.js +++ b/index.js @@ -10,12 +10,16 @@ module.exports = function(opt) { var stream; + if (opt == null) { + opt = {}; + } stream = through.obj(function(file, enc, callback) { var templateString; if (file.isNull()) { this.push(file); return callback(); } else if (file.isBuffer()) { + opt['filename'] = file.path; templateString = jade.compileClient(file.contents.toString(), opt).toString(); file.contents = new Buffer('module.exports = ' + templateString); file.path = replaceExt(file.path, '.js');