Sha256: f84b3043d688a7ecab595634b22f144ca7a16798674f983800cc5fb03a085c96

Contents?: true

Size: 663 Bytes

Versions: 7

Compression:

Stored size: 663 Bytes

Contents

# htmlescape

Properly escape JSON for usage as an object literal inside of a `<script>` tag. Use `htmlescape` in place of `JSON.stringify`. For more info see [JSON: The JavaScript subset that isn't](http://timelessrepo.com/json-isnt-a-javascript-subset).

## Transformations

| from     | to        |
| -------- |:---------:|
| `&`      | `\\u0026` |
| `>`      | `\\u003e` |
| `<`      | `\\u003c` |
| `\u2028` | `\\u2028` |
| `\u2029` | `\\u2029` |


## Usage

```js
var htmlescape = require('htmlescape');
htmlescape({prop:'value'});
//=> '{"prop":"value"}'
```

Or in your templates:

```html
<script>
var payload = <%= htmlescape(payload) %>;
</script>
```

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
minimum_viable_product-0.0.11 test/dummy/node_modules/htmlescape/README.md
brwy_rails-0.0.6 test/dummy/node_modules/htmlescape/README.md
brwy_rails-0.0.5 test/dummy/node_modules/htmlescape/README.md
brwy_rails-0.0.4 test/dummy/node_modules/htmlescape/README.md
brwy_rails-0.0.3 test/dummy/node_modules/htmlescape/README.md
brwy_rails-0.0.2 test/dummy/node_modules/htmlescape/README.md
brwy_rails-0.0.1 test/dummy/node_modules/htmlescape/README.md