documentcloud/underscore — pull request #505 by braddunbar (2012-03-11 16:54:44+00:00)
Title: Allow natural multi-line code evaluation in templates.

From the docs:

> Template functions can both interpolate variables, using <%= … %>, as well as execute arbitrary JavaScript code, with <% … %>.

This is not quite true as there are certain restrictions on how arbitrary the code can be. For instance, the following template will not run as expected:

```
<%
var foo;
// some comment
foo = 15;
%>
...
<%= foo %>
...
```

Since `_.template` joins all lines of evaluated code with a space, a single line comment or a line of code without a terminating semicolon will cause a syntax error when creating the template function. By escaping `\r`, `\n`, and `\t` earlier, we can unescape them along with backslashes and single quotes allowing for the inclusion of single line comments and code without a terminating semicolon. This change is backwards compatible in most cases and allows code to be more completely arbitrary. Furthermore, debugging is made easier since all the code is not on one line.