An open API service indexing awesome lists of open source software.

https://github.com/dbspt/scorpion-html

Scorpion-core support pack
https://github.com/dbspt/scorpion-html

Last synced: 2 months ago
JSON representation

Scorpion-core support pack

Awesome Lists containing this project

README

          

# Scorpion HTML
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

Scorpion-core support pack.

### Installation

```console
$ npm install @dbservices/scorpion-html
```

### Features, Usage, and Examples

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

```typescript
import html from "@dbservices/scorpion-html";

console.log(html`

${"Scorpion HTML"}

`); // =>

Scorpion HTML


```

- **Safe by default.** For example:

```typescript
console.log(html`

${`alert(1);`}

`); // =>

<script>alert(1);</script>


```

- **Unsafely interpolate trusted HTML with `$${...}`.** For example:

```typescript
console.log(html`

$${`Scorpion HTML`}

`); // =>

Scorpion HTML


```

- **Join interpolated arrays.** For example:

```typescript
console.log(html`

${["Scorpion", " ", "HTML"]}

`); // =>

Scorpion HTML


```

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