11

Better Abstractions for HTML Views

This chapter will focus on classic, HTML-first Ruby on Rails applications and their data representation features, or, simply speaking, HTML views. First, we discuss built-in mechanisms for generating views in Rails, such as ERB templates and view helpers, and their drawbacks. Then, we consider an alternative approach to overcome these drawbacks and reduce the overall complexity of managing the HTML layer—view components.

We will cover the following topics:

  • The V in Rails’ MVC: templates and helpers
  • Thinking in components

The goal of this chapter is to demonstrate how object-oriented techniques can help you to keep the view layer organized and, thus, maintainable.

Technical requirements

In this chapter ...

Get Layered Design for Ruby on Rails Applications 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.