multilines

The missing template literal for NodeJS.

Usage no npm install needed!

<script type="module">
  import multilines from 'https://cdn.skypack.dev/multilines';
</script>

README

If this package reaches anyone from NPM, please let me know if we could change the name to multilinestring.

multilines

npm version CircleCI codecov

The missing template literal for NodeJS.

Overview

multilines removes all spaces before | character and first space after if present.

  • 💅 Prettier code style: You no longer have to care about spaces in multiline strings!
  • 🌳 Zero dependencies: Completely self contained!
  • 💡 Inspired by Scala code style: Used by the best, now implemented for everyone.

Installation

yarn add multilines

Example

import mls from 'multilines'

// Before

function generate(...args) {
  const string = `
I have to start at the beggining of the line
so I don't break the string indentation.
  `
}

// After

function generate(...args) {
  const string = mls`
    | I can be aligned with other code
    | and everything still works as expected.
    `
}

License

MIT @ Matic Zavadlal