Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/cdxoo/block-quote

simple indent sanitization for multi line strings
https://github.com/cdxoo/block-quote

indent multi-line string

Last synced: 18 days ago
JSON representation

simple indent sanitization for multi line strings

Awesome Lists containing this project

README

        

# @cdxoo/block-quote
Simple indent sanitization for multi line strings via tag for template literals in es6.

## Installation

npm install --save @cdxoo/block-quote

## Usage

```javascript
const bq = require('@cdxoo/block-quote');

let str1 = bq`
alice
foo
bar
bob
baz
`;
// | <- beginning of the line
// => |alice
// | foo
// | bar
// |bob
// | baz

// also works when code itself is indented deeper
// and placeholders are used; e.g.:
let getInner = () => (
(
(
bq`
inner {
foo
bar
}
`
)
)
);
let str1 = bq`
outer {
${ getInner() }
}
`;
// => |outer {
// | inner {
// | foo
// | bar
// | }
// |}
```