Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change template engine of node.js project?

I have this node.js project, it uses jade template. But I need to use simple html pages. Guideline needed for safe transformation.

I need to use complete .html pages like index.html, login.html. Without any template engine to show at routes like localhost:3000 and localhost:3000/login.html. Which should work with full functionality.

like image 509
XIMRX Avatar asked Oct 21 '25 00:10

XIMRX


2 Answers

You can change it in config/express.js:

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

For example, if you want to use Handlebars, then remove "jade": "latest", in packages.json and add "handlebars": "latest". Then run npm install and edit config/express.js:

 app.set('view engine', 'handlebars')
like image 196
Gergo Erdosi Avatar answered Oct 23 '25 15:10

Gergo Erdosi


Express server static html files by default.

Place your html files in /public folder:

    ...
    /public
       index.html
       login.html
       ...

and go localhost:3000/ or localhost:3000/login.html but this is static files and then the application logic should be on the front-end. For example using angular or backbone.

like image 36
diproart Avatar answered Oct 23 '25 16:10

diproart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!