title: Why does jQuery templates add double quotes to some strings
body: <p><strong>Background</strong></p>
  
  <p>I'm working with jQuery templates, ASP.Net MVC Razor views and Twitter. </p>
  
  <p><strong>Problem</strong></p>
  
  <p>Using jQuery templates with some strings automatically results in those strings being wrapped in "</p>
  
  <p><strong>Details</strong></p>
  
  <p>I created a jQuery template that looks like this:</p>
  
  <pre><code>&lt;script id="twitterResultsTemplate" type="text/x-jquery-tmpl"&gt;
          &lt;div class="tweetItem"&gt;
              &lt;div class="userAvatar"&gt;&lt;img src="${profile_image_url}" alt="${from_user} Image" /&gt;&lt;/div&gt;
              &lt;div class="tweetSummary"&gt;
                  &lt;div class="bd"&gt;before ${text.parseUserName().parseHashTag()} after&lt;/div&gt;
                  &lt;div&gt;${created_at}&lt;/div&gt;
                  &lt;div class="ft"&gt;${prettyDate(created_at)}&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;        
          &lt;br style="clear: both;" /&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>The following javascript formats the username and hash tags</p>
  
  <pre><code>String.prototype.parseUsername = function () {
      return this.replace(/[@]+[A-Za-z0-9-_]+/g, function (u) {
          var username = u.replace("@", "")
          return u.link("http://twitter.com/" + username);
      });
  };
  
  String.prototype.parseHashtag = function () {
      return this.replace(/[#]+[A-Za-z0-9-_]+/g, function (t) {
          var tag = t.replace("#", "%23")
          return t.link("http://search.twitter.com/search?q=" + tag);
      });
  };
  </code></pre>
  
  <p>Unfortunately, what's happening is that the text is being wrapped inside double-quotes. So, </p>
  
  <p><strong>What I expect to get is:</strong></p>
  
  <pre><code>&lt;div&gt;before @user Hello World #hello #world after&lt;/div&gt;
  </code></pre>
  
  <p><strong>Instead, what I get is:</strong></p>
  
  <pre><code>&lt;div&gt;"before @user Hello World #hello #world after"&lt;/div&gt;
  </code></pre>
  
  <p>Why are double quotes automatically being inserted? More importantly, how do I prevent it or fix it?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have determined that this only happens when <code>@</code> is included in the text . . . which happens any time a username is included.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I'm not exactly sure why this solution works, but it does. I'll update this post later as I get a better understanding of the problem.</p>
  
  <p>Change (doesn't work)</p>
  
  <pre><code>&lt;div class="bd"&gt;before ${text.parseUserName().parseHashTag()} after&lt;/div&gt;
  </code></pre>
  
  <p>To: (works)</p>
  
  <pre><code>&lt;div class="bd"&gt;before {{html text.parseUserName().parseHashTag()}} after&lt;/div&gt;
  </code></pre>