Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix template not found #41

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ Hbs.prototype.createRenderer = function() {
var tplPath = hbs.getTemplatePath(tpl),
template, rawTemplate, layoutTemplate;

if(tplPath === undefined) {
this.status = 500;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't a pattern I'm familiar with koa-hbs using. personally think it'd be better to throw here than anything. status = 500 doesn't really mean anything, does it? only thing that comes to mind is an http 500 error, which wouldn't be 'not found'.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shellscape thank you for starting a discussion about this. I looked into this a bit more, and I agree with your suggestion. #42 is the tracking issue to utilize the standard koa error handling mechanisms.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to mention, there won't be a release with this change. There will be a new minor version once #42 closes.

this.body = 'Template: ' + tpl + ' not found';
return;
}

locals = merge(this.state || {}, locals || {});
locals = merge(hbs.locals, locals);

Expand Down