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

Windows: cannot use absolut path in layout-option of response.render #2580

Closed
Tineler opened this issue Mar 9, 2015 · 5 comments
Closed
Assignees
Labels

Comments

@Tineler
Copy link

Tineler commented Mar 9, 2015

Following call:

   router.get('/hello', function(req, res) {
       res.render(__dirname + '/views/home.handlebars', {
           layout: __dirname + '/views/layouts/main.handlebars',
           markup: markup // Pass rendered react markup
       });
    });

leads to following error message:
Error: ENOENT, open D:\ZHAW\BA\IoT_Base\lib\views\layouts\D:\ZHAW\BA\IoT_Base\lib\plugins\IoT_HelloWorld\views\layouts\main.handlebars'

Seems to me, as if the path is handled relative even though it's obviously absolute.

@Twipped
Copy link

Twipped commented Mar 9, 2015

What handlebars engine are you using? Express doesn't do any view loading itself, so your issue would be with it.

@Tineler
Copy link
Author

Tineler commented Mar 9, 2015

I am using express-handlebars.

@Twipped
Copy link

Twipped commented Mar 9, 2015

Yeah, you'll need to take it up with them, all Express does is pass the res.render arguments to express-handlebars. It's up to it to resolve those paths properly.

@Tineler Tineler closed this as completed Mar 9, 2015
@Tineler
Copy link
Author

Tineler commented Mar 9, 2015

Okay, I'll try. that. Thanks. :-)

@dougwilson dougwilson self-assigned this Mar 10, 2015
@dougwilson
Copy link
Contributor

@ChiperSoft is correct in how Express is working :) We basically use path.resolve to resolve your views directory (which is where "D:\ZHAW\BA\IoT_Base\lib\views\layouts" came from). Then after that, we take all the arguments to res.render and look at the first one ("D:\ZHAW\BA\IoT_Base\lib\plugins\IoT_HelloWorld\views\layouts\main.handlebars"). Since it is an absolute path, we just do nothing and pass it to your view engine and let it process all this information :)

I see you created ericf/express-handlebars#113 for anyone else who comes by.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants