Skip to content

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.

License

clhenrick/single-line-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 (eg: Node >= 4.7.0).

Usage

ES6

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

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/

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published