質問

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');

役に立ちましたか?

解決

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.

他のヒント

this way works too:

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

someone knows any problem using this way?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top