title: Google Apps Script: Line breaks in templated HTML scriptlets
body: <p>If I have an HTML file test.html:</p>
  
  <pre><code>&lt;p&gt;&lt;?= str ?&gt;&lt;/p&gt;
  </code></pre>
  
  <p>And a script function:</p>
  
  <pre><code>var t = HtmlService.createTemplateFromFile("test.html");
  t.str = "test\nstring";
  var content = t.evaluate().setSandboxMode(...).getContent();
  Logger.log(content);
  </code></pre>
  
  <p>Is there any way to safely replace the newline with an HTML line break? I can use String.prototype.replace() to replace <code>\n</code> with <code>&lt;br/&gt;</code>, but then I'd have to use <code>&lt;?!=</code> to disable the HTML templating engine's contextual escaping. I'm dealing with untrusted input and so I need both escaping and smart handling of line breaks. Having it contextually would be nice. As things stand, I wrote my own escaper, but it is only good for one context.</p>