-
Notifications
You must be signed in to change notification settings - Fork 383
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
Templates break when empty #18
Comments
Can you describe the steps so that I can reproduce this? Is it just an empty template file, or a template file which does not exist on the file system? |
It's any empty template file. Here are exact steps to reproduce:
var express = require('express');
var router = express();
var express_handlebars = require('express3-handlebars');
var express_handlebars_config = {
extname: '.hbs',
partialsDir: 'views',
layoutsDir: 'views'
};
var handlebars = express_handlebars.create( express_handlebars_config );
router.engine( 'hbs', handlebars.engine );
router.set( 'view engine', 'hbs' );
router.set( 'views', 'views' );
router.get( '/', function( req, res ){
res.render( 'index.hbs', {} );
});
router.get( '/test', function( req, res ){
res.render( 'test.hbs', {} );
});
router.listen( 8080 );
<!DOCTYPE>
<html>
<body>test.hbs</body>
</html>
|
So the root issue is that in the most recent, released (1.10.0) version of Handlebar does a falsy check in its Instead of making ExpressHandlebars handle this case, I'd rather wait until the next version of Handlebars is released which will automatically correct this. Does that work for you? |
I'll wait on the change to be released in Handlebars, then updated here. Thanks for looking into it! |
This was fixed in handlebars-lang/handlebars.js#461 |
Looks like this is in Handlebars 1.0.11, so we can close this issue out. |
Having issues with empty templates again.
I feel the dependency should be specified as 1.0.x to make sure this type of issue (some dependency changing from underneath you) doesn't happen. |
I want Being able to control which version of Handlebars is used was a primary design decision for this package. Add the version you want in your app's // Will load the `handlebars` module specified in your app's package.json
// instead of the version that `express3-handlebars` has in its `node_modules/` dir.
app.engine('.handlebars', exphbs({handlebars: require('handlebars')})); |
@ericf Great, thanks. That makes sense. I did end up specifying the handlebars version in my |
If I run an empty template through express3-handlebars, I get this response from every template:
The text was updated successfully, but these errors were encountered: