Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/steelbrain/tagged-template-literals
- Owner: steelbrain
- License: mit
- Created: 2016-03-18T10:44:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-01T22:29:03.000Z (about 7 years ago)
- Last Synced: 2024-08-09T21:27:02.230Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
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)
): stringmodule.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