1.0.1 • Published 4 years ago

@cdxoo/block-quote v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

@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

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
//    |    }
//    |}