title: Razor declarative helper used as javascript string
body: <p>Assuming i have a helper such as:</p>
  
  <pre><code>@helper AddErrorSpan(string error)
  {
      &lt;span class="error"&gt;@error&lt;/span&gt;
  }
  </code></pre>
  
  <p>I run in to issues attempting to call the helper in javascript.  For example:</p>
  
  <pre><code>if ($('#YearTextBox').val() == "") 
  {
          $('#ErrorDiv').append('@AddErrorSpan("Year field is required.")');
  }
  </code></pre>
  
  <p>This fails and causes a javascript syntax error because the helper returns a newline at the end.  This causes the trailing <code>');</code> to be pushed to the next line causing the syntax error.  Is there anything I can do to remedy this easily?  Currently the easy solution is to make the helper like this.</p>
  
  <pre><code>@helper AddErrorSpan(string error)
  {&lt;span class="error"&gt;@error&lt;/span&gt;}
  </code></pre>
  
  <p>Since there's no break before the closing <code>}</code> the new line isn't returned from the helper and there is no javascript syntax error.  This is kind of annoying and just ugly to look at.  Is there a way to keep the helper from returning the newline when called in my javascript method?</p>