Search code examples
node.jsexpressparse-platformejs

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


How would I go about using .html extensions on my view files instead of .ejs when using Parse.com's Express.js?

I changed the EJS delimiters to <? and ?> because I'm used to them from PHP. That worked fine, but I can't seem to change the file extension for my view files:

I've 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've also tried eliminating this line with the same result:

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


Solution

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

    So I did app.set to html and app.engine to html and it was working for me.