ember-cli-dompurify
v0.1.0
Published
Use DOMPurify in your Ember.js application
Downloads
3
Readme
ember-cli-dompurify
====================================================================================
Use DOMPurify in your Ember application
Compatibility
- Ember.js v3.24 or above
- Ember CLI v3.24 or above
- Node.js v14 or above
Installation
ember install ember-cli-dompurify
Configuration
Most usages of DomPurify should be satisfied by the helper.
If you need to use custom arguments for all of your calls to .sanitize
, apply the configuration to your environment.js under the domPurify key. See the DomPurify documentation for more information about the available options.
# config/environment.js
...
domPurify: {
WHOLE_DOCUMENT: true,
RETURN_DOM: true,
ADD_URI_SAFE_ATTR: ['my-attr']
...
},
...
If you need to use custom arguments for only one of many calls to .sanitize
, use the service, which allows you to supply custom arguments to each invocation of .sanitize
. See Usage below for more details.
Usage
Helper (uses global config)
# my-component.hbs
{{dom-purify myTextContent}}
Service (uses global and supplied config)
# my-component.js
import { service } from '@ember/service';
...
@service domPurify;
...
this.domPurify.sanitize(myTextContent, {LOCAL_CONFIG_OPTION: value})
Contributing
See the Contributing guide for details.
License
This project is licensed under the MIT License.