Introducing The Automatic View Library

by Zach Briggs

Simple things should be easy and hard things should be possible when we’re building web apps. I work in Ruby on Rails which is great at database backed, server rendered apps. What Rails doesn’t help with is dynamic user interfaces, that is web pages that update themselves via JavaScript.

If your Rails project has a UI that isn’t well served by a widget library, such as a jQuery plugin, then you should consider including an automatic view library. This is a term that I needed to invent, and I apologize for that. However, we didn’t have a combination of words that covered the need to create novel and engaging user experiences!

An automatic view library

  • Renders arbitrary trees of DOM nodes
  • Updates the DOM nodes based on user actions and changes to data
  • Loops - able to render a collection
  • If - Conditionally renders
  • Provides a means of abstraction, usually through nested components

If you ever have to worry about an element's inner html, you're not using an automatic view library. If you have to manually re-render a template after data changes, that's not an automatic view library.

Not Automatic View Libraries

  • Handlebars - This is a template library which requires that you manually re-render when data changes.
  • Backbone.js - This isn't even a view library, much less an automatic view library; its render function is a no-op by default.
  • Select2 - Doesn't allow arbitrary DOM trees which makes this a widget library
  • jQuery - Does not automatically update DOM nodes for the user.

Automatic view libraries

Single page app focused frameworks that contain an automatic view library

Automatic view libraries are interesting to me because they allow us to embed islands of interactivity into an otherwise server rendered page. We can compose arbitrary and novel dynamic user experiences without committing to the overhead of a single page app.

Check out The Spice House’s new website. Our team at Table XI constructed it using views that are 90% Rails and 10% Vue, and I am very proud of the work we did.