Q:

View engine error when sending registration email in loopback

I am just kicking off a new project using loopback. I have created a new model based on the standard user model and I am now implementing registration and login by following the tutorials.
I have registration emails configured and sending via Gmail however I get an error in the console -
Error: No default engine was specified and no extension was provided.

The tutorial uses ejs as the outbound email template and I thought this was the default for loopback so not sure why I would be getting this error.  I have read a couple of posts about changing to jade which talk about configuring (jade) in the server.js file.
My question is should loopback be picking up ejs automatically?
If not and I need to configure it manually is server.js the place to do it or should it be a config file setting e.g. config.json.

A:

The view engine isn't set by default in loopback and you need to set it. To configure EJS template.
Since loopback is based on express. So you need to follow the express approach to set the view engine.

First install the EJS template. 
$ npm install ejs --save
Also open terminal go to the root folder and type.
$ mkdir views && mkdir views/static
Here views/ folder will be the base folder for the Views and views/static will be the base folder for serving static files css/js/image etc
Now inside the server/boot/root.js file. comment the following lines.
//var router = server.loopback.Router();
//router.get('/', server.loopback.status());
//server.use(router);
Now add these lines to the server/boot/root.js folder
 module.exports = function(server) {
   var loopback = require('loopback');

 //Now setting up the static files..
 server.use('/static', loopback.static(__dirname + '/../../views/static'));

 // set the view engine to ejs
 server.set('view engine', 'ejs');

 //Now set the index page for the  '/' route
 server.get('/', function(req, res) {
   res.render('index', data);
 });

}

Now finally add a index.ejs file to views/ to load.

