trailsjs / trails

:evergreen_tree: Modern Web Application Framework for Node.js.
http://trailsjs.io
Other
1.66k stars 70 forks source link

view engine not loading #95

Open grd2345 opened 8 years ago

grd2345 commented 8 years ago

I installed trails and got the app to run, but view engine is not loading. I tried to set it up as jade, i installed jade but seems it does not load the view engine. how do you properly setup this stuff as I see no info about this.

screenshot from 2016-01-25 19 12 33

edencorbin commented 8 years ago

Not sure on Jade, but this worked for me on EJS, and should be very similar,

Config/views.js in your module exports add engine: 'ejs', In your package.json add dependency for ejs: "ejs": "^2.4.1", npm install.

You can now start your app and you won't get a view engine error, however you still will get an error about the view not existing. I'm working on figuring out the view routing part too. Any link to documentation is currently rerouting me to the github page, Am I missing the docs?

grd2345 commented 8 years ago

You get view not existing because the server.js file under the trailpack-hapi module is hard coded to look for html view which is handlebars. I got this working by adding jade to it. I'm sure you can add ejs and it will work. The latest update still hasn't corrected this.

Not sure on Jade, but this worked for me on EJS, and should be very similar,

Config/views.js in your module exports add engine: 'ejs', In your package.json add dependency for ejs: "ejs": "^2.4.1", npm install.

You can now start your app and you won't get a view engine error, however you still will get an error about the view not existing. I'm working on figuring out the view routing part too. Any link to documentation is currently rerouting me to the github page, Am I missing the docs?

— Reply to this email directly or view it on GitHub https://github.com/trailsjs/trails/issues/95#issuecomment-193779799.

JAertgeerts commented 7 years ago

This works fine using the property: engine: require('jade') When you want to use multiple engines, configure it in web.js.

The whole view configuration feels weird though - allowing a single view engine in views.js and multiple in web.js feels odd.

scott-wyatt commented 7 years ago

@trailsjs/maintainers, v3 or v4 milestone? We are passed deadline for both, so my vote is for v4.

jaumard commented 7 years ago

@scott-wyatt it's only trailpack hapy and express related so it can be done when we want to update those trailpack I think