vue-insane

1.0.1 • Public • Published

vue-insane

Vue plugin for insane sanitizer

Usage

  npm install vue-insane
  yarn add vue-insane

Install as plugin, will install the instance method $sanitizeHTML() and the v-sanitize-html directive.

import Vue from 'vue'
import VueInsanePlugin from 'vue-insane'

Vue.use(VueInsanePlugin, {
  .../*insane options*/
})


//only directive 
import { insaneDirective } from 'vue-insane'
Vue.directive('sanitize-html', insaneDirective)

Usage on components

<template>
  <div>
    <!-- As method -->
    <p v-html="$sanitizeHTML(content)" />

    <!-- As Directive -->
    <p v-sanitize-html="content" />

    <!-- Set the 'strict' option to true -->
    <p v-sanitize-html.strict="content" />
  </div>
</template>
<script>
export default {
  data(){
    return {
      content: `<div><p>Hello World!</p></div>`
    }
  }
}
</script>

$sanitizeHTML(html, options, strict)

param type description
html string The HTML string to sanitize
options object The insane's options object. It will be merged with the options defined in the plugin registration.
strict boolean The strict param of insane function.

Package Sidebar

Install

npm i vue-insane

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

2.4 kB

Total Files

7

Last publish

Collaborators

  • federico.mameli