singleline

Convert a multi line string into a single line string - great for classnames and more

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
singleline
2.0.03 years ago6 years agoMinified + gzip package size for singleline in KB

Readme

singleline
Build status Convert a multiline string to a single line string ---

Getting started

Install the dependency npm install singleline --save-dev

React classNames example

```js import singleline from 'singleline'; ...
rrs__select-container
rrs__select-container--multiselect
${(disabled === true) ? 'rrs__select-container--disabled' : ''}
${(isTouchDevice === true) ? 'rrs__is-touch' : 'rrs__is-desktop'}
${(isOptionsPanelOpen === true) ? 'rrs__options-container--visible' : ''}
${altered ? 'rrs__has-changed': ''}
`)}
Some output
// className="rrsselect-container rrsselect-container--multiselect rrsis-desktop rrsoptions-container--visible" ```

Example 2

Passing second parameter in as true, removes spaces around the HTML tags but it still respects the spaces in the contents of the tags and attributes. ```js import singleline from 'singleline'; var testMultilineHTMLString = singleline(`
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GDD - Giphy Github embed Gif code explorer</title>
<link href="css/styleguide.css" rel="stylesheet">
<div id="root" class="root"></div>
<script src="app.js"></script>
`, true); console.log(testMultilineHTMLString); // 'GDD - Giphy Github embed Gif code explorer
' ```