title: using require and backbone to load templates via html file and not script tag
body: <p>I have a very simple web page which is using backbone simply to load a view from a template file:</p>
  
  <pre><code>&lt;div id="content"&gt;&lt;/div&gt;
  
  &lt;script src="js/vendor/json2.js"&gt;&lt;/script&gt;
      &lt;script src="js/vendor/jquery-2.0.2.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/vendor/underscore-min.js"&gt;&lt;/script&gt;
      &lt;script src="js/vendor/backbone-min.js"&gt;&lt;/script&gt;
      &lt;script src="js/flight-match-form.js"&gt;&lt;/script&gt;
      &lt;script type="text/template" id="template-flight-match"&gt;
        &lt;section id="form-search" class="content-inner clearfix"&gt;
          &lt;div id="date-container" class="search-row clearfix"&gt;
            &lt;label class="search-label" for="date"&gt;Travel Date&lt;/label&gt;
            &lt;img src="images/structure/icon-calendar.png" alt="calendar" class="calendar"&gt;
            &lt;span class="help-text" id="date-unknown"&gt;don't know it?&lt;/span&gt;
          &lt;/div&gt;
          &lt;div id="flight-container" class="search-row clearfix"&gt;
            &lt;label class="search-label" for="date"&gt;FLIGHT #&lt;/label&gt;
            &lt;input type="text" class="search-input" id="input-flight" pattern="[a-zA-Z0-9]+"&gt;
            &lt;span class="help-text" id="date-unknown"&gt;don't know it?&lt;/span&gt;
          &lt;/div&gt;
          &lt;button id="button-match"&gt;
            Match
            &lt;img src="images/structure/icon-arrow.png" height="15" width="20" alt="Submit Arrow"&gt;
          &lt;/button&gt;
        &lt;/section&gt;
      &lt;/script&gt;
  </code></pre>
  
  <p>and in flight-match-form.js, I simply say:</p>
  
  <pre><code>$(document).ready(function(){
  
      var MatchView = Backbone.View.extend({
          initialize: function(){
              this.render();
          },
          render: function(){
              // Compile the template using underscore
              var template = _.template( $("#template-flight-match").html(), {} );
              // Load the compiled HTML into the Backbone "el"
              this.$el.html( template );
          }
      });
  
      var matchView = new MatchView({ el: $("#content") });
  
  });
  </code></pre>
  
  <p>This works great, and all I really wanted to do next was to get all that html out of a script tag and into a proper HTML file, where I think it belongs. So, does anyone know the simplest way to do this?</p>
  
  <p>I tried to follow <a href="http://backbonetutorials.com/organizing-backbone-using-modules/" rel="nofollow">this tutorial</a>, and it lead me down this big rabbit hole where I ended up using require.js and the text module, and a router, and two new js files (main and app), along with a view and a template. I'm currently getting an error in the view stating that Backbone cannot read property 'view' of undefined. This is my code:</p>
  
  <p>In index.html, I include require.js, and make it reference main.js as the inital file:</p>
  
  
  
  <p>then in main.js, I specify a template directory, and send it off to app.js:</p>
  
  <pre><code>require.config({
    paths: {
      jquery: 'vendor/jquery/jquery-2.0.2.min',
      underscore: 'vendor/underscore/underscore-min',
      backbone: 'vendor/backbone/backbone-min',
      templates: '../templates'
    }
  });
  
  require([
    'app',
  ], function(App){
    App.initialize();
  });
  </code></pre>
  
  <p>In app.js, I initialize the router:</p>
  
  <pre><code>define([
    'jquery',
    'underscore',
    'backbone',
    'router', // Request router.js
  ], function($, _, Backbone, Router){
    var initialize = function(){
      // Pass in our Router module and call it's initialize function
      Router.initialize();
    };
  
    return {
      initialize: initialize
    };
  });
  </code></pre>
  
  <p>and in router.js, I set up a route for my view:</p>
  
  <pre><code>// Filename: router.js
  define([
    'jquery',
    'underscore',
    'backbone',
    'views/search/SearchFormView'
  ], function($, _, Backbone, SearchFormView) {
  
    var AppRouter = Backbone.Router.extend({
      routes: {
        // Define some URL routes
        'search': 'SearchFormView'
      }
    });
  
    var initialize = function(){
  
      var app_router = new AppRouter;
  
      app_router.on('route:SearchFormView', function(){
  
          // Call render on the module we loaded in via the dependency array
          var searchView = new SearchFormView();
          searchView.render();
  
      });
      Backbone.history.start();
    };
    return {
      initialize: initialize
    };
  });
  </code></pre>
  
  <p>Lastly, I just create that view, which will load my template:</p>
  
  <pre><code>define([
    'jquery',
    'underscore',
    'backbone',
    'text!templates/search/search-form-template.html'
  
  ], function($, _, Backbone, searchFormTemplate){
    var SearchFormView = Backbone.View.extend({
      initialize: function(){
          this.render();
      },
      render: function(){
          // Compile the template using underscore
          var template = _.template( $("#template-flight-match").html(), {} );
          // Load the compiled HTML into the Backbone "el"
          this.$el.html( template );
      }
    });
    return SearchFormView;
  });
  </code></pre>
  
  <p>but it's not working, and I can't figure out why. Any help is much appreciated. Apologize for the excessive amount of code, but all of it seems to be necessary just to load this stuff the proper way.</p>