Skip to content

Commit

Permalink
relative path in error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario L Gutierrez committed Jan 23, 2014
1 parent 7b74631 commit a50e673
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hbs.js
Expand Up @@ -420,7 +420,7 @@ function _express3(filename, source, options, cb) {
source = fs.readFileSync(filename, 'utf8');
template = self.handlebars.compile(source);
// for error message
template.__filename = filename.substring(filename.lastIndexOf(path.sep) + 1, filename.length);
template.__filename = path.relative(self.viewsDir, filename);
if (options.cache) {
self.cache[filename] = { source: source, template: template };
}
Expand Down
22 changes: 22 additions & 0 deletions test/issues.js
Expand Up @@ -183,6 +183,28 @@ describe('issue-49', function() {
done();
});
});

it('should report relative filename with error', function(done) {
var hb = hbs.create()
var render = hb.express3({});
var locals = H.createLocals('express3', dirname, {});
render(dirname + '/front/error.hbs', locals, function(err, html) {
assert(err.stack.indexOf('front/error.hbs') > 0);
done();
});
});

it('should report filename with partial error', function(done) {
var hb = hbs.create()
var render = hb.express3({
partialsDir: dirname + '/partials'
});
var locals = H.createLocals('express3', dirname, {});
render(dirname + '/partial.hbs', locals, function(err, html) {
assert(err.stack.indexOf('partial.hbs') > 0);
done();
});
});
});


1 change: 1 addition & 0 deletions test/issues/49/front/error.hbs
@@ -0,0 +1 @@
{{{http://google.co.uk}}
1 change: 1 addition & 0 deletions test/issues/49/partial.hbs
@@ -0,0 +1 @@
{{> partial-error}}
1 change: 1 addition & 0 deletions test/issues/49/partials/partial-error.hbs
@@ -0,0 +1 @@
{{http://google.co.uk}

0 comments on commit a50e673

Please sign in to comment.