Using express without a template engine

前端 未结 4 1264
眼角桃花
眼角桃花 2021-01-17 23:59

Is it possible to create an express (node) application without the need for a template engine such as jade or ejs. I\'ve got a large final year project at university and i\'

4条回答
  •  时光说笑
    2021-01-18 00:28

    The best option right now is to use ejs (engine) and configure it to accept and render html:

    app.set('views', path.join(*__dirname*, 'views'))
    app.set('view engine', 'ejs'); // template engine
    app.engine('html', require('ejs').renderFile); // turn engine to use html
    

    Note: All your views or templates have the .html extension.

提交回复
热议问题