title: How do you embed other programming languages into your code?
body: <p>Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into our C# code.  To accomplish this, there seems to be two prevalent schools of thought:</p>
  
  <pre><code>string blah = "asdf";
  StringBuilder someJavaScript = new StringBuilder();
  someJavaScript.Append("&lt;script language='JavaScript' &gt;");
  someJavaScript.Append("function foo()\n");
  someJavaScript.Append("{\n");
  someJavaScript.Append("  var bar = '{0}';\n", blah);
  someJavaScript.Append("}\n");
  someJavaScript.Append("&lt;/script&gt;");
  </code></pre>
  
  <p>The other school of thought is something like this:  </p>
  
  <pre><code>string blah = "asdf";
  string someJavaScript = @"
      &lt;script language='JavaScript' &gt;
      function foo()
      {
        var bar = '" + blah + @"';
      }
      &lt;/script&gt;";
  </code></pre>
  
  <p>Is there a better way than either of these two methods?  I like the second personally, as you can see the entire section of JavaScript (or other language block, whether SQL or what have you), and it also aids in copying the code between another editor for that specific language.</p>
  
  <p>Edit:<br>
  I should mention that the end goal is having formatted JavaScript in the final web page.</p>
  
  <p>I also changed the example to show interaction with the generated code.</p>