Comparing version 0.0.1 to 0.0.3
42
index.js
@@ -6,4 +6,5 @@ 'use strict'; | ||
var staticModule = require('static-module'); | ||
var quote = require('quote-stream'); | ||
var resolve = require('resolve'); | ||
var assign = require('object-assign'); | ||
var stringify = require('js-stringify'); | ||
var jade = require('jade'); | ||
@@ -20,13 +21,8 @@ | ||
var vars = { | ||
var vars = assign({ | ||
__filename: file, | ||
__dirname: path.dirname(file), | ||
require: { resolve: resolver } | ||
}; | ||
}, opts.vars); | ||
if (opts.vars) | ||
Object.keys(opts.vars).forEach(function( key ){ | ||
vars[key] = opts.vars[key]; | ||
}); | ||
var sm = staticModule({ | ||
@@ -42,25 +38,31 @@ jade: { | ||
function resolver(p){ | ||
return resolve.sync(p, { basedir: path.dirname(file) }); | ||
return sm; | ||
function resolver( p ){ | ||
return resolve.sync(p, { | ||
basedir: path.dirname(file), | ||
}); | ||
} | ||
return sm; | ||
function renderFile( file, opts ){ | ||
var markup = quote(); | ||
var render = jade.compileFile(file, opts); | ||
markup.end(jade.renderFile(file, opts)); | ||
track(sm, [ file ].concat(render.dependencies)); | ||
sm.emit('file', file); | ||
return markup; | ||
return stringify(render(opts)); | ||
} | ||
function render( source, opts ){ | ||
var markup = quote(); | ||
var render = jade.compile(source, opts); | ||
markup.end(jade.render(source, opts)); | ||
track(sm, render.dependencies); | ||
return markup; | ||
return stringify(render(opts)); | ||
} | ||
}; | ||
function track( sm, files ){ | ||
files.forEach(function( file ){ | ||
sm.emit('file', file); | ||
}); | ||
} |
{ | ||
"name": "brjade", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"description": "Turn jade.render and jade.renderFile calls into inlined markup", | ||
@@ -11,6 +11,7 @@ "repository": { | ||
"static-module": "^1.1.2", | ||
"quote-stream": "^0.0.0", | ||
"resolve": "^1.1.6", | ||
"jade": "^1.9.2", | ||
"through2": "^0.6.3" | ||
"through2": "^0.6.3", | ||
"object-assign": "^2.0.0", | ||
"js-stringify": "^1.0.0" | ||
}, | ||
@@ -17,0 +18,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2410
3
50
6
+ Addedjs-stringify@^1.0.0
+ Addedobject-assign@^2.0.0
+ Addedjs-stringify@1.0.2(transitive)
+ Addedobject-assign@2.1.1(transitive)
- Removedquote-stream@^0.0.0