title: Backbone, Underscore, Require.js routing and template issues (Uncaught TypeError: Cannot read property 'replace' of undefined )
body: <p>Need a help for a very weird situation I am in with BB, _, and require. I use Grunt's assemble.io to precompile my html, so at any given moment I have all my templates in one and the same file. I will be more clear, I have this is my index.html:</p>
  
  <pre><code>&lt;div class="container"&gt; 
      &lt;div class="main-container"&gt;
         &lt;script type="text/template" id="login-template"&gt; 
            bla bla bla
         &lt;/script&gt;
         &lt;script type="text/template" id="register-template"&gt;
           tralalala
         &lt;/script&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my router:</p>
  
  <pre><code>define(['backbone', 'underscore', '../views/homeView', '../views/registerUserView' ],            function(Backbone, _, HomeView, RegisterUserView) {
  
  var homeView = new HomeView(),
      registerUserView = new RegisterUserView();
  
  var Router = Backbone.Router.extend({
      routes: {
        '' : 'home',
        'register/:id': 'registerUser'
      }
   });
  
  var router = new Router();
  router.on('route:home', function(){
     homeView.render();
  });
  router.on('route:registerUser', function(id){
    registerUserView.render(id);
  });
  
  Backbone.history.start();
  
  return Router;
  });
  </code></pre>
  
  <p>This is my Register View:</p>
  
  <pre><code>define(['backbone', 'underscore'], function(Backbone, _) {
  
    var RegisterUserView = Backbone.View.extend({
  
    el : '.main-container',
  
    render : function (id) {
        var _this = this,
            _template = _.template($('#reg-user-main-template').html(), {} );
           //todo: create the switch 
        _this.$el.html(_template);
      },
  
      initialize: function() {
     }
   });
  
   return RegisterUserView;
  </code></pre>
  
  <p>});</p>
  
  <p>I have a button with href="#register/1", that when I click gives me the:</p>
  
  <p>Uncaught TypeError: Cannot read property 'replace' of undefined localhost/js/libs/underscore-amd/underscore.js:1180</p>
  
  <p>So I know that this happens, because the _template = _.template($('#reg-user-main-template').html(), {} ); is getting an "undefined" for  $('#reg-user-main-template'), but I don't know why or how, since all my templates are in the same html file. Any help will be greatly appreciated and I am sure that the Karma or whatever will give you many beers if you help :)</p>