Home > Web Front-end > JS Tutorial > body text

When node.js uses the ejs template engine, the suffix is ​​changed to .html_node.js

WBOY
Release: 2016-05-16 16:02:46
Original
1192 people have browsed it

This is a little trick. I always feel uncomfortable looking at the .ejs suffix. Use the following method to change the suffix of the template file to the .html we are used to.

1. Define ejs at the head of app.js:

Copy code The code is as follows:

var ejs = require('ejs');

2. Register html template engine:

Copy code The code is as follows:

app.engine('html',ejs.__express);

3. Change the template engine to html:

Copy code The code is as follows:

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

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

Okay, the task is completed, you can run and watch the effect!

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template