koajs / koa-hbs

Handlebars templates for Koa.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Empty handlebars template should not be problem.

pilwon opened this issue · comments

When a handlebars template file is empty, koa-hbs middleware seems to yield instead of rendering an empty web page.

Would you mind posting your configuration passed to koa-hbs please? thanks!

@jwilm

app.use(require('koa-hbs').middleware({
  viewPath: __dirname + '/views'
}));

Working on this now - were you getting a 404? I don't know what you mean by "seems to yield", but when I try to render a blank template, it gives me a 404. The test added in above commit shows this for me:

  1) rendering with an empty template should render a blank page:
     Error: expected 200 "OK", got 404 "Not Found"

@jwilm Please disregard my seems to yield comment. It may be caused by other middlewares I have in the pipe. I trust the test result.

The 404 didn't make sense to me, and there was an issue with the test. The test now properly generates a 200 OK with no body.

@jwilm This is very interesting. Now that you mentioned that it should work properly, I tested it again and it seems to behave as expected. I'm not really sure how to best explain this, but my assumption is the empty template files were in a funny state or something. Not sure. Anyways, I think we can close this issue, and I will report if I discover anything like that again. Thanks~

Unless you have some objection, I am going to merge the test and close the issue. Thanks for using koa-hbs! ❤️

edit: oops, you beat me to it!

@jwilm You will see koa-hbs used in the new koa version of ultimate-seed some time later :)

Sweet!