Code Walkthrough

In notebook:
FrontEndMasters BackboneJS
Created at:
2016-05-29
Updated:
2016-06-08
Tags:
JavaScript libraries
First sample:
  // main.js
define(function(require, exports, module){

  var $ = require('jquery');
  var App = require('./app');

  $(function(){
    window.comments = new App();
  });

});
Then goes through the main app.js file. Basically the same as what we went through so far.

Instantiating a ​PersoneModel()​ and ​CommentsCollection()​ etc.
comment-view.js 

talks about require being able to load template files through a middleware layer. So the template file can be a separate file, like a handlebars template file.

Argues against ever mixing HTML markup text strings and javascript in the same place. Use templating or another deliberate solution. 

Separate layers of your code into standalone elements!

Backbone has ​model.escape()​ to guard against cross site scripting. 

Uses EJS templates. It’s logic-full template unlike Handlebars or Mustache. Sometimes you do need some logic in your templates. 
You can run any JS inside EJS templates. Can use helper methods that are on the model. e.g:
  // comment-view.js

...
// (shows how many minutes ago a comment was posted)
formatDate: function (){
  var date = moment(this.model.get('created_at'));
  return date.fromNow();
}
Talks about the importance of module files. Makes testing easier.
More you isolate you elements the easier your tests will be. The less you have side effects (modules help reduce side effects) the less setup you have to do for testing.