1.0.2 • Published 2 years ago

@dbservices/scorpion-html v1.0.2

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

Scorpion HTML

Commitizen friendly

Scorpion-core support pack.

Installation

$ npm install @dbservices/scorpion-html

Features, Usage, and Examples

  • Use tagged template literals as an HTML template engine. For example:

    import html from "@dbservices/scorpion-html";
    
    console.log(html`<p>${"Scorpion HTML"}</p>`); // => <p>Scorpion HTML</p>
  • Safe by default. For example:

    console.log(html`<p>${`<script>alert(1);</script>`}</p>`); // => <p>&#x3C;script&#x3E;alert(1);&#x3C;/script&#x3E;</p>
  • Unsafely interpolate trusted HTML with $${...}. For example:

    console.log(html`<p>$${`<span>Scorpion HTML</span>`}</p>`); // => <p><span>Scorpion HTML</span></p>
  • Join interpolated arrays. For example:

    console.log(html`<p>${["Scorpion", " ", "HTML"]}</p>`); // => <p>Scorpion HTML</p>

    Array interpolations are safe by default; if you wish to unsafely interpolate an array of trusted HTML use $${[...]}.