title: Backbone.js calling a function in a template returns undefined
body: <p>I am building a todo application and I have task view which renders a task template and every task has a category chosen by the user. Each task has a CategoryId property. I want to display the category of each task. So I have the following function in the task view:</p>
  
  <pre><code>getCategoryName: function (categoryId) {
      return app.Categories.each(function (category) {
          if (categoryId === category.get('CategoryId')) {
              return category.get('CategoryName');
          }
      });
  }
  </code></pre>
  
  <p>Here's the task template:</p>
  
  <pre><code>&lt;script type="text/template" id="taskTemplate"&gt;
  &lt;div class="view"&gt;
      &lt;input class="toggle" type="checkbox" &lt;%= Completed ? 'checked' : '' %&gt; /&gt;
      &lt;label class="title"&gt;&lt;%- Description %&gt;&lt;/label&gt;
      &lt;section class="info"&gt;
          &lt;span class="category"&gt;&lt;%- this.getCategoryName(CategoryId) %&gt;&lt;/span&gt;
      &lt;/section&gt;
      &lt;button class="destroy"&gt;&lt;/button&gt;
  &lt;/div&gt;
  &lt;input class="edit" value="&lt;%- Description %&gt;" /&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>I call the getCategoryName function and pass the CategoryId of the task. Then the function loops over every category and checks if the passed CategoryId matches an id of a category in the Category collection and then returns the name of the matched category. But no category displays. So I think I'm not returning the name of the category properly. When I console.log it in the callback function it appears in the console but it is not returned.</p>
  
  <p>Do you have any ideas? Could you suggest a solution of this problem?
  Thanks.</p>