trailsjs / trails

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

Cannot render view without a views manager configured #221

Open zechtz opened 8 years ago

zechtz commented 8 years ago

I am trying to use ejs with trails but i keep on getting this error Cannot render view without a views manager configured

Here's my views.js

module.exports = {
  views: {
    engines:  { ejs: require('ejs') },
    path:     'views'
  }
}

ViewController.js

  helloWorld (request, reply) {
    reply.view('index', {
        title: "EJS"
    });
  }

What could be the problem?

jaumard commented 8 years ago

views.js should look like this:

module.exports = {
  engine: require('ejs')
}
zechtz commented 8 years ago

Hey @jaumard This is the error i am still getting

trails

This is how my code looks using hapi

code

jaumard commented 8 years ago

@zechtz I never used the hapi version but here is what I use for express https://github.com/jaumard/trails-example-express-gulp/blob/master/config/views.js#L7 and in fact require is not needed sorry.

I just check the README of trailpack-hapi and all is here : https://github.com/trailsjs/trailpack-hapi#view-config :)

or alternatively in web.js : https://github.com/trailsjs/trailpack-hapi#hapi-views

Also if you create the views.js manually check it's loaded under index.js or the file is ignored

zechtz commented 8 years ago

Thanks, let me just try it with express.

tjwebb commented 8 years ago

@weyj4 do you have any ideas on this?

scott-wyatt commented 8 years ago

Actually, Trails just checks that their is an engine present, not wether the engine is valid. We found this out when we put in an invalid engine and express defaulted to serving an index.html.