Change from Jade template to ejs for MEAN Stack

2019-08-11 11:30发布

I am currently new to use MEAN stack with the following packages: https://github.com/linnovate/mean. However, after I had created the project and found that Jade is their default template engine.

Are there any good ways to convert those jade template to ejs with changing related settings in Express?

Thank you.

2条回答
小情绪 Triste *
2楼-- · 2019-08-11 11:45

Inside app.js change:

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

to

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

then

  1. Open your jade-based page on chrome browser.

  2. Open the mouse context-menu on browser and select "inspect element".

  3. Select the html tag and copy it as HTML.

  4. Paste that HTML on your favorite HTML editor or any code editor.

  5. Adjust some tags to fit to 'ejs'. For example, change 'block body' to '<%- body%> or change any data string to a data variable like {{data}} or & quot; to " ' ".

  6. save the files with ejs instead of jade.

查看更多
孤傲高冷的网名
3楼-- · 2019-08-11 12:11
var express = require('express');
var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');// here you set EJS
查看更多
登录 后发表回答