openoakland/opendisclosure — pull request #277 by tdooner (2014-09-07 00:47:23+00:00)
Title: Add handlebars for JS templating

@KyleW @vbrown608 @mikeubell What do you think about this? It should make our views much easier to maintain -- no slashes at the end of lines required!

----
There is a convenient gem 'handlebars_assets' which will put any
handlebars template in assets/js/templates/(filename).hbs into a global
JS variable `HandlebarsTemplates['(filename)']`. This *should* work with
asset precompilation as well.

The main reason is maintainability... the candidate template had
spiraled out of control in complexity and this seems a lot more
reasonable to me.

The only downside is that you have to be a lot more explicit with the
variables / context you pass into the rendering, which is kind of a
drag because it requires more logic in the Backbone view. But that seems
relatively nice to me, since that means the view itself is much simpler.