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
- Using
EEx
to pass helper functions at the time of evaluation - Testing the view module
- Creating a new web application using
Goldcrest
By the end, we will have an interface to simplify defining EEx templates with an...