title: How to pass additional variables in to underscores templates
body: <p>I've a backbone view that renders a search result in a underscore template. As I want to highlight the search term in the result I have the following print method in the template:</p>
  
  <pre><code>print(someKey.replace(searchTerm, '&lt;b&gt;' + searchTerm + '&lt;/b&gt;')
  </code></pre>
  
  <p>It works as aspected, but I have to set the <code>searchTerm</code> variable in the global namespace to get this work. I wonder if there is a way to access my views model in the print method, so I could write it like this:</p>
  
  <pre><code>print(someKey.replace(searchTerm, '&lt;b&gt;' + this.model.get('searchTerm') + '&lt;/b&gt;')
  </code></pre>
  
  <p>Or if I could set searchTerm as a local variable in my render function and access it in my template. </p>
  
  <p>Here is the whole Backbone view:</p>
  
  <pre><code>var searchTerm;
  var SearchResultView = Backbone.View.extend({
      initialize: function() {
          this.model.bind('change:rows', this.render, this);
          this.model.bind('change:searchTerm', this.clear, this)
      },
      template: _.template("&lt;tr&gt;&lt;td&gt;&lt;% print(someKey.replace(searchTerm, '&lt;b&gt;' + searchTerm + '&lt;/b&gt;')); %&gt;&lt;/td&gt;&lt;/tr&gt;", this),
      render: function() {
         searchTerm = this.model.get('searchTerm')
          _.each(this.model.get('rows'), function(row) {
              this.el.append($(this.template(row.doc)));
          }, this)
      },
      clear: function(){
          this.el.empty();
      }
  });
  </code></pre>