title: Using Closure compiler with Underscore.js _.template
body: <p>Is there any way to compile Underscore.js templates on the server <strong>and</strong> get the Closure compiler to work with the generated code?</p>
  
  <p>The main problem is that <code>_.template</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>_.template = function(str, data) {
      var c  = _.templateSettings;
      var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
          'with(obj||{}){__p.push(\'' +
          str.replace(/\\/g, '\\\\')
          .replace(/'/g, "\\'")
          .replace(c.interpolate, function(match, code) {
              return "'," + code.replace(/\\'/g, "'") + ",'";
          })
          .replace(c.evaluate || null, function(match, code) {
              return "');" + code.replace(/\\'/g, "'")
                  .replace(/[\r\n\t]/g, ' ') + "__p.push('";
          })
          .replace(/\r/g, '\\r')
          .replace(/\n/g, '\\n')
          .replace(/\t/g, '\\t')
          + "');}return __p.join('');";
      var func = new Function('obj', tmpl);
      return data ? func(data) : func;
  };
  </code></pre>
  
  <p>generates JavaScript with a with-statement in it. The two obvious routes are:</p>
  
  <ol>
  <li>modify Underscore.js's <code>_.template</code> not to generate withs </li>
  <li>coerce Closure into playing nice</li>
  </ol>
  
  <p>Is the second option possible?</p>