title: Angular2 Pipes: output raw HTML
body: <p>I'm trying to create an Angular2 custom pipe that outputs raw html. I want it to simply convert newlines in the input into HTML line breaks. How do I output raw HTML from an angular2 pipe?  </p>
  
  <p>The following is my current pipe definition, but it escapes the HTML which I don't want:</p>
  
  <pre><code>import {Pipe, PipeTransform} from '@angular/core';
  /*
   * Converts newlines into html breaks
  */
  @Pipe({ name: 'newline' })
  export class NewlinePipe implements PipeTransform {
      transform(value: string, args: string[]): any {
          return value.replace(/(?:\r\n|\r|\n)/g, '&lt;br /&gt;');
      }
  }
  </code></pre>
  
  <p>EDIT: Just a quick note since this question seems to get a number of views and activity that I'm leaving my accepted answer as is, even though for my specific example use-case css probably would have been a better option and was in fact what I changed to. But my actual question was "how do I output raw html from an angular 2 pipe", not "what's the best way to render line breaks" which is what the accepted answer shows. </p>
  
  <p>Beware though, as mentioned in comments below, if you do use the method in the accepted answer you need to ensure that you're not rendering unchecked user input as this could open you up to XSS vulnerabilities.</p>