Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clhenrick/single-line-string
Simple tag function that converts multiline ES6 template literals to a single line string & removes extra whitespace. Requires a javascript environment that supports template literals.
https://github.com/clhenrick/single-line-string
es2015 es6 es6-javascript template-literals
Last synced: about 1 month ago
JSON representation
Simple tag function that converts multiline ES6 template literals to a single line string & removes extra whitespace. Requires a javascript environment that supports template literals.
- Host: GitHub
- URL: https://github.com/clhenrick/single-line-string
- Owner: clhenrick
- License: mit
- Created: 2016-12-26T14:54:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-28T00:23:05.000Z (over 7 years ago)
- Last Synced: 2024-09-15T22:00:24.381Z (2 months ago)
- Topics: es2015, es6, es6-javascript, template-literals
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Single Line String
Simple tag function that converts a multiline ES6 template literal to a single line
string, removing extra whitespace. Requires a javascript environment that supports
[es6 template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
(eg: Node >= 4.7.0).## Usage
ES6```javascript
import sls from 'single-line-string';var name = 'June';
const hello = sls`
Hey,
hello,
how
are
you
${name}?
`console.log(hello); // outputs: "Hey, hello, how are you June?"
```or via Common JS
```javascript
var sls = require('single-line-string');
var name = 'June';
var hello = sls`
Hey,
hello,
how
are
you
${name}?
`;console.log(hello); // outputs: "Hey, hello, how are you June?"
```## Install
`npm install single-line-string`## Build
`npm install && npm run build`## Test
`npm run test`## Credits
code credit: https://muffinresearch.co.uk/removing-leading-whitespace-in-es6-template-strings/