|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | # Dedent
|
|---|
| 2 |
|
|---|
| 3 | An ES6 string tag that strips indentation from multi-line strings.
|
|---|
| 4 |
|
|---|
| 5 | ## Usage
|
|---|
| 6 |
|
|---|
| 7 | ```js
|
|---|
| 8 | import dedent from "dedent";
|
|---|
| 9 |
|
|---|
| 10 | function usageExample() {
|
|---|
| 11 | const first = dedent`A string that gets so long you need to break it over
|
|---|
| 12 | multiple lines. Luckily dedent is here to keep it
|
|---|
| 13 | readable without lots of spaces ending up in the string
|
|---|
| 14 | itself.`;
|
|---|
| 15 |
|
|---|
| 16 | const second = dedent`
|
|---|
| 17 | Leading and trailing lines will be trimmed, so you can write something like
|
|---|
| 18 | this and have it work as you expect:
|
|---|
| 19 |
|
|---|
| 20 | * how convenient it is
|
|---|
| 21 | * that I can use an indented list
|
|---|
| 22 | - and still have it do the right thing
|
|---|
| 23 |
|
|---|
| 24 | That's all.
|
|---|
| 25 | `;
|
|---|
| 26 |
|
|---|
| 27 | const third = dedent(`
|
|---|
| 28 | Wait! I lied. Dedent can also be used as a function.
|
|---|
| 29 | `);
|
|---|
| 30 |
|
|---|
| 31 | return first + "\n\n" + second + "\n\n" + third;
|
|---|
| 32 | }
|
|---|
| 33 | ```
|
|---|
| 34 |
|
|---|
| 35 | ```js
|
|---|
| 36 | > console.log(usageExample());
|
|---|
| 37 | ```
|
|---|
| 38 |
|
|---|
| 39 | ```
|
|---|
| 40 | A string that gets so long you need to break it over
|
|---|
| 41 | multiple lines. Luckily dedent is here to keep it
|
|---|
| 42 | readable without lots of spaces ending up in the string
|
|---|
| 43 | itself.
|
|---|
| 44 |
|
|---|
| 45 | Leading and trailing lines will be trimmed, so you can write something like
|
|---|
| 46 | this and have it work as you expect:
|
|---|
| 47 |
|
|---|
| 48 | * how convenient it is
|
|---|
| 49 | * that I can use an indented list
|
|---|
| 50 | - and still have it do the right thing
|
|---|
| 51 |
|
|---|
| 52 | That's all.
|
|---|
| 53 |
|
|---|
| 54 | Wait! I lied. Dedent can also be used as a function.
|
|---|
| 55 | ```
|
|---|
| 56 |
|
|---|
| 57 | ## License
|
|---|
| 58 |
|
|---|
| 59 | MIT
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.