Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

misc refactoring

  • Loading branch information...
commit 138bceaae9ec22b8d8949fd2d0c667be474d7886 1 parent 51cdf62
@tj tj authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/jade.js
View
12 lib/jade.js
@@ -153,11 +153,11 @@ function rethrow(err, str, filename, lineno){
}
/**
- * Parse the given `str` of jade and return a `Function`.
+ * Parse the given `str` of jade and return a function body.
*
* @param {String} str
* @param {Object} options
- * @return {Function}
+ * @return {String}
* @api private
*/
@@ -178,12 +178,12 @@ function parse(str, options){
}
try {
- return new Function('locals', ''
+ return ''
+ attrs.toString()
+ escape.toString()
+ 'var buf = [];\n'
+ 'with (locals) {' + js + '}'
- + 'return buf.join("");');
+ + 'return buf.join("");';
} catch (err) {
process.compile(js, filename || 'Jade');
return;
@@ -224,13 +224,13 @@ exports.render = function(str, options){
if (cache[filename]) {
fn = cache[filename];
} else {
- fn = cache[filename] = parse(str, options);
+ fn = cache[filename] = new Function('locals', parse(str, options));
}
} else {
throw new Error('filename is required when using the cache option');
}
} else {
- fn = parse(str, options);
+ fn = new Function('locals', parse(str, options));
}
// Render the template
Please sign in to comment.
Something went wrong with that request. Please try again.