Categories
JavaScript Answers

How to get Express to output nicely formatted HTML?

Spread the love

Sometimes, we want to get Express to output nicely formatted HTML.

In this article, we’ll look at how to get Express to output nicely formatted HTML.

How to get Express to output nicely formatted HTML?

To get Express to output nicely formatted HTML, we set the app.locals.pretty option to true.

For instance, we write

if (app.get('env') === 'development') {
  app.locals.pretty = true;
}

to set app.locals.pretty to true when our Express app is run in the dev environment.

Conclusion

To get Express to output nicely formatted HTML, we set the app.locals.pretty option to true.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *