Change the .ejs extension to .html using Parse.com Express.js

How can I use .html extensions in my view files instead of .ejs when using Parse.com Express.js?

I changed the EJS delimiters to <? and ?> because I'm used to them with PHP. This worked fine, but I cannot change the file extension for my files of the form:

I tried the following:

 var express = require('express'); var ejs = require('ejs'); var app = express(); ejs.open = '<?'; ejs.close = '?>'; app.set('view engine', 'ejs'); app.engine('.html', ejs.renderFile); app.set('views', 'cloud/views'); app.use(express.bodyParser()); app.get('/', function(req, res) { res.render('Test', { message: 'Hello Express!' }); }); app.listen(); 

And I get an internal server error.

I also tried to exclude this line with the same result:

app.set('view engine', 'ejs');

+8
source share
2 answers
 app.set('view engine', 'html'); app.engine('html', ejs.renderFile); 

So, I made app.set for html and app.engine for html and it worked for me.

+23
source

this method also works:

 app.set('view engine', 'html'); app.engine('html',require('ejs').renderFile); 

Does anyone know any problem using this method?

+1
source

All Articles