ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 382 forks source link

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

Closed Tineler closed 9 years ago

Tineler commented 9 years ago

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.

ericf commented 9 years ago

@Tineler Yeah, this would need to change so that it works with Windows paths and not just Unix-style ones: https://github.com/ericf/express-handlebars/blob/master/lib/express-handlebars.js#L331-333

Tineler commented 9 years ago

Seems legit. Do you mind if I fork the repo and create a pull-request after fixing it? Because I need it pretty soon. :-)