Skip to content

Commit

Permalink
added back in helpers for parse()
Browse files Browse the repository at this point in the history
Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
  • Loading branch information
conancat authored and tj committed Jul 15, 2011
1 parent b99ce74 commit 92ac584
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions lib/jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,13 @@ function parse(str, options){
}

try {
var str = ''
return ''
+ helpers
+ 'var buf = [];\n'
+ (options.self
? 'var self = locals || {}, __ = __ || locals.__;\n' + js
: 'with (locals || {}) {' + js + '}')
+ 'return buf.join("");';
if (options.compileDebug !== false) {
str = helpers + str;
}

return str;

} catch (err) {
process.compile(js, filename || 'Jade');
Expand Down Expand Up @@ -258,6 +254,8 @@ exports.compile = function(str, options){
fn = parse(String(str), options || {});
}

console.log(new Function('locals', fn).toString());

return new Function('locals', fn);
};

Expand Down
8 changes: 4 additions & 4 deletions test/jade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,13 @@ module.exports = {
},

'test .compile() with inline helpers': function(assert){
var fn = jade.compile('p foo\np bar', {helpers: 'inline'});
assert.equal('<p>foo</p><p>bar</p>', fn());
var fn = jade.compile('p foo\np #{bar}', {helpers: 'inline'});
assert.equal('<p>foo</p><p>baz</p>', fn({bar: 'baz'}));
},

'test .compile() no debug': function(assert){
var fn = jade.compile('p foo\np bar', {compileDebug: false});
assert.equal('<p>foo</p><p>bar</p>', fn());
var fn = jade.compile('p foo\np #{bar}', {compileDebug: false});
assert.equal('<p>foo</p><p>baz</p>', fn({bar: 'baz'}));
},

'test null attrs on tag': function(assert){
Expand Down

0 comments on commit 92ac584

Please sign in to comment.