Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/cdxoo/block-quote
- Owner: cdxOo
- License: mit
- Created: 2020-04-07T11:15:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T15:52:11.000Z (7 months ago)
- Last Synced: 2024-12-04T04:07:46.851Z (about 1 month ago)
- Topics: indent, multi-line, string
- Language: JavaScript
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
// | }
// |}
```