Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/steelbrain/tagged-template-literals

A base library to make your packages simpler.
https://github.com/steelbrain/tagged-template-literals

Last synced: 10 days ago
JSON representation

A base library to make your packages simpler.

Awesome Lists containing this project

README

        

Tagged Template Literals
=====================

[![Greenkeeper badge](https://badges.greenkeeper.io/steelbrain/tagged-template-literals.svg)](https://greenkeeper.io/)
Tagged Template Literals is a base library to make your packages simpler. See the usage for example usage.

## Installation

```sh
npm install --save tagged-template-literals
```

## API

```js
function taggedTemplateLiterals(
strings: Array,
values: Array,
callback: ?((param: string) => string)
): string

module.exports = taggedTemplateLiterals
```

## Examples
```js
import escape from 'escape-html'
import taggedTemplate from 'tagged-template-literals'

function escapeHTML(strings, ...values) {
if (!strings && !strings.raw) {
throw new Error('Only template strings are supported')
}
return taggedTemplate(strings, values, escape)
}

const dangerous = ''
const escaped = escapeHTML`
Hello there


${dangerous}

`)
console.log(escaped === `
Hello there

<script></script>

`) // true
```

## License

This project is licensed under the terms of MIT License, see the LICENSE file for more info