node.jsmongodbexpresstemplate-engine

Node.js without a template engine


I'm new into Node.js and trying to learn. From what I have understood it's common to use a template engine (eg. Jade), even for CSS (eg. Stylus). To be honest, all the tutorials I have seen out there involve a template engine when it comes to the layout.

The thing is that I don't want to use a template engine because I think it's unnecessarily complex.

Here is a link to a boilerplate for Node (unfortunately it doesn't work by some reason), but Option 1 shouldn't be using any template engine for the layout.

So, what is the easiest way to combine Node.js and Mongodb with "normal" HTML(5)? Is it possible for example to use HMTL5 Boilerplate with Node?


Solution

  • Using express, you would just send the html5 in the response:

    app.get('/', function(req, res){
      res.send('<header>Hello World</header>');
    });
    

    However, I would say that in most cases a templating engine doesn't add complexity. The separation of concerns makes things simpler if you are rendering dynamic content.