I come from a very strict OOP flash background, and I’m really trying to get deeper into backbone, my question is this:
If I have classes for all views (much like in flash), are there any uses/benefits of the _.template functionality for me, or can i just overlook it for now?
Markup templating, whether with underscore or any other templating framework, is most definitely useful.
It seems that you see View classes and templates as somewhat of a either-or proposition., but that’s not really the case. They solve a different problem altogether; they complement each other, not replace.
A view class (
Backbone.Viewin your case) scopes and encapsulates the view-related logic and event handling. This is great practice, and should be used whether or not you decide to use a templating engine.Templates on the other hand simply transpose your data to the HTML, nothing more or less. This is something your view needs to do, and the way I see it, there are a few ways of achieving this:
"<div>" + this.model.name + "</div>"… ugh)$(".name").text(this.model.name)ad absurdum…Choice is yours, but I wouldn’t go without either a data binding or a templating framework. The templates provided by underscore are powerful, but I prefer semantic, logic-less templates such as Handlebars.