Skip to content

Commit

Permalink
Merge 1f5475b into fbc04cf
Browse files Browse the repository at this point in the history
  • Loading branch information
MarsiBarsi committed Sep 4, 2019
2 parents fbc04cf + 1f5475b commit 36b6a50
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,37 @@ $ npm install @tinkoff/ng-dompurify
Either use pipe to sanitize your content when binding to `[innerHTML]`
or use `NgDompurifySanitizer` service manually.

```typescript
import {NgDompurifyModule} from '@tinkoff/ng-dompurify';

@NgModule({
imports: [NgDompurifyModule],
})
export class MyModule {}
```

As a pipe:

```html
<div [innerHtml]="value | dompurify"></div>
```

As a service:

```typescript
import {SecurityContext} from '@angular/core';
import {NgDompurifySanitizer} from '@tinkoff/ng-dompurify';

@Component({})
export class MyComponent {
constructor(private readonly dompurifySanitizer: NgDompurifySanitizer) {}

purify(value: string): string {
return this.dompurifySanitizer.sanitize(SecurityContext.HTML, value);
}
}
```

You can also substitute entire Angular `DomSanitizer` with `DOMPurify`:

```typescript
Expand Down

0 comments on commit 36b6a50

Please sign in to comment.