Express Generator Without Jade

后端 未结 6 1204
南方客
南方客 2021-02-07 03:46

I am trying to generate an express skeleton, using the express generator. So it would be this:

$ npm install express-generator -g

However, it

6条回答
  •  抹茶落季
    2021-02-07 04:14

    You can just delete the jade files and hook up your own template engine.

    For example, I like using Handlebars.js. So in order to use that, in app.js or server.js or whatever the generator names the main file, you'd substitute the line:

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

    with something along the lines of this (after installing and requiring handlebars, at least):

    app.engine('handlebars', exphbs({defaultLayout: 'main'}));
    app.set('view engine', 'handlebars');
    

    And every engine is as configurable as you want it o be.

提交回复
热议问题