# trust-html-pipe

> Pipe for angular2+ projects which allows you to inject non-escaped HTML content into your templates.

Latest version **1.0.0** (published 2019-06-25) · 0 weekly downloads

## Install

```sh
npm install trust-html-pipe
pnpm add trust-html-pipe
yarn add trust-html-pipe
bun add trust-html-pipe
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-06-25 |
| First published | 2017-05-28 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 29.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | tvicpe |
| Maintainers | kageoni |
| Keywords | trust-html, trustHtml, inject, html, trust, angular, angular2, pipe, trust-html-pipe, trustHtmlPipe |

## Links

- npm: https://www.npmjs.com/package/trust-html-pipe
- Repository: https://github.com/tvicpe/trust-html-pipe
- Homepage: https://github.com/tvicpe/trust-html-pipe#readme
- Issues: https://github.com/tvicpe/trust-html-pipe/issues
- npm.io page: https://npm.io/package/trust-html-pipe

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-06-25
- 0.0.6 — 2017-06-08
- 0.0.5 — 2017-06-01
- 0.0.4 — 2017-05-31
- 0.0.3 — 2017-05-31
- 0.0.2 — 2017-05-28

## README

trust-html-pipe
=====
1. [Description](#description)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Methods](#methods)
5. [Git repository](#git)
6. [Build](#build)
7. [Publish to npm](#publish)
8. [Version](#version)

### <a name="description"></a>1. Description
`trust-html-pipe` or `TrustHtmlPipe` is a pipe for angular2 projects 
which allows you to inject the HTML content into your templates.
  
### <a name="installation"></a>2. Installation
Install the module into your application and save it as a dev 
dependency in your `package.json` file  
```
npm install trust-html-pipe --save-dev
```

### <a name="usage"></a>3. Usage
In order to use the `TrustHtmlPipe` you have to include/import 
the `TrustHtmlModule` into your application:

```typescript
import {TrustHtmlModule} from 'trust-html-pipe';

@NgModule({
  //...
  imports: [
    //...
    TrustHtmlModule
  ],
  //...
})
```
  
Or you can include the pipe directly in your components declarations list in your `@NgModule(...)`:
```typescript
import {TrustHtmlPipe} from "trust-html-pipe";

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

Use it in your template to "inject" trusted HTML content:
```angular2html
<div [innerHTML]="'<strong>test html content</strong>' | trustHtml"></div>
```
  
Output:
```html
<div>
  <strong>test html content</strong>
</div>
```
  
  
### <a name="methods"></a>4. Methods
  
#### transform(htmlString: string): any
Bypass security and trust the given value to be safe HTML. 
The sanitizer will leave safe HTML intact.  
**WARNING:** in Angular version 2.x, calling this method with untrusted user data exposes your 
application to XSS security risks!
  
*Parameters:*  
**htmlString** - HTML string which should not be escaped.  
  
*Return:*  
Method returns the intact HTML string.  
  
  
### <a name="git"></a>5. Git repository
[https://github.com/tvicpe/trust-html-pipe](https://github.com/tvicpe/trust-html-pipe)

### <a name="build"></a>6. Build
To build the final package run this command:
```
ng build trust-html
```
The build process will generate the packed sources into the `dist` folder.  

### <a name="publish"></a>7. Publish to npm
To publish the new version to `npm`, go into the `dist` folder:
```
cd ./dist/trust-html
```
and publish it to npm:
```
npm publish
```

### <a name="version"></a>8. Version
1.0.0

---
_Source: https://npm.io/package/trust-html-pipe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
