Code Monkey home page Code Monkey logo

nl2br-pipe's Introduction

nl2br-pipe

  1. Description
  2. Installation
  3. Usage
  4. Methods
  5. Git repository
  6. Version

1. Description

nl2br-pipe or Nl2BrPipe is a pipe for angular2 projects which replaces the new line characters \n in a string with the <br /> tag.

2. Installation

Install the module into your application and save it as a dev dependency in your package.json file

npm install nl2br-pipe --save-dev

3. Usage

In order to use the Nl2BrPipe you have to include/import it into your application:

import {Nl2BrPipe} from "nl2br-pipe";

Include it in your components declarations list in your @NgModule(...):

@NgModule({
  //...
  declarations: [Nl2BrPipe],
  //...
})

Use it in your template to replace new line characters \n with the <br /> tag:

<div [innerHTML]="'<strong>test html content</strong>\nnew line\nthird line' | nl2br"></div>

Output:

<div>
  <strong>test html content</strong><br />new line<br />third line
</div>

4. Methods

transform(value: string): string

Replace the new line characters \n in a string with the <br /> tag Bypass security and trust the given value to be safe HTML. The sanitizer will leave safe HTML intact and will replace new line character \n with the <br /> tag.
WARNING: calling this method with untrusted user data exposes your application to XSS security risks!

Parameters:
value - string where to replace \n with <br /> and not to escape the HTML tags.

Return:
Method returns the new string containing <br /> tag instead of \n.

5. Git repository

https://github.com/tvicpe/nl2br-pipe

6. Version

0.0.6

nl2br-pipe's People

Contributors

tvicpe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.