1.0.1 • Published 3 years ago

vue-insane v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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)

paramtypedescription
htmlstringThe HTML string to sanitize
optionsobjectThe insane's options object. It will be merged with the options defined in the plugin registration.
strictbooleanThe strict param of insane function.