Change from Jade template to ejs for MEAN Stack

限于喜欢 提交于 2019-12-11 10:11:19

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/20998129/change-from-jade-template-to-ejs-for-mean-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!