When node.js uses the ejs template engine, replace the template page suffix with .html

This is a little trick. Looking at the suffix of .ejs is always uncomfortable. Using the following method, you can change the suffix of the template file to the .html that we are used to.

1. Define ejs on the head of app.js:
var ejs = require ('ejs');

2. Register the html template engine:
app.engine ('html', ejs .__ express);

3. Replace the template engine with html:
app.set ('view engine', 'html');

4. Modify the suffix of the template file to .html.

Well, the task is completed, you can run to watch the effect!

Guess you like

Origin www.cnblogs.com/homehtml/p/12680916.html