7

Working with Views

In the last few chapters, we learned how to render an HTML response for our web framework using the controller itself. In this chapter, we will learn about the view component that will be responsible for performing that rendering in a much better way. We will first extract some of the rendering and EEx logic to the new view module, and then define helper functions that will help us to render HTML and can be called in from the EEx template itself. We will then write a complete example application using the current state of our web framework.

The following are the topics that this chapter will cover:

  • What is a view and what are its responsibilities?
  • Defining a view module
  • Calling a view module from the controller module

Get Build Your Own Web Framework in Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.