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

https://github.com/towerofnix/fix-whitespace

A tiny library that fixes whitespace in JavaScript template strings.
https://github.com/towerofnix/fix-whitespace

es6 string string-modification template-strings whitespace

Last synced: 6 days ago
JSON representation

A tiny library that fixes whitespace in JavaScript template strings.

Awesome Lists containing this project

README

        

# fix-whitespace

A tiny library that fixes whitespace in JavaScript template strings.

```js
const items = [1, 2, 3]

const generateSitePage = (head, content) => fixWhitespace`



(Begin head..)${head}(..End head)




${"Early insert!"} (Begin content x1..)${content}(..end content; begin content x2..)${content}(..end content!)
${"And back down."}



`

console.log(generateSitePage(
fixWhitespace`
Hello, world!
`,

fixWhitespace`

    ${items.map(x => `
  • ${x}
  • `).join('\n')}

`
))
```

```html


(Begin head..)Hello, world!(..End head)




Early insert! (Begin content x1..)

  • 1

  • 2

  • 3


(..end content; begin content x2..)

  • 1

  • 2

  • 3


(..end content!)
And back down.

```

## Documentation

[Read the code!](fix-whitespace.js)