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.
- Host: GitHub
- URL: https://github.com/towerofnix/fix-whitespace
- Owner: towerofnix
- License: mit
- Created: 2017-04-15T18:57:13.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-02T20:25:42.000Z (over 4 years ago)
- Last Synced: 2025-05-26T07:21:39.944Z (about 1 month ago)
- Topics: es6, string, string-modification, template-strings, whitespace
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/fix-whitespace
- Size: 12.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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)