O'Reilly logo

Developing a hapi Edge: A Rich Node.js Framework for Apps and Services by Foreword by Eran Hammer, Lloyd Benson, Daniel Bretoi, Van Nguyen, Wyatt Preul

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Templating

In the last chapter (Chapter 8 Models), we saw how easy it was to obtain and store data. Now, we will see how to present the data back to the user.

Hapi is primarily intended for building RESTful JSON APIs. However, when working in the web, it is often essential or helpful to respond to HTTP requests with HTML to be rendered by a browser. Since the output responses depend on the input, or on which user requests the data, it is not always possible or ideal to simply hardcode the same response for every response. The best method to customize responses is with templating. In hapi, templates are referred to as views.

Hapi supports most templating engines out of the box. This chapter will include working examples for six of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required