# indented

> Better indented multi line strings than regular template strings

Latest version **0.1.0** (published 2023-01-19) · 0 weekly downloads

## Install

```sh
npm install indented
pnpm add indented
yarn add indented
bun add indented
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-01-19 |
| First published | 2023-01-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aminnairi |

## Links

- npm: https://www.npmjs.com/package/indented
- npm.io page: https://npm.io/package/indented

## Recent versions

- 0.1.0 (latest) — 2023-01-19

## README

# indented

Better indented multi line strings than regular template strings

## Why

Using multiline strings in a deeply nested block can be tedious even when using template strings in JavaScript because they keep the extra space added when indenting the code, making it hard to create properly indented blocks of strings that span over multiple lines. This library is here to fix this behavior.

This is particularily useful when creating blocks of code that needs to be indented inside of a template string for instance.

## How

This library will take every lines and compute the minimum whitespace length possible for a line (ignoring empty lines).

Once it got that, it will simply remove the right amount of space needed to output the string as if it were written with the correct amount of space, even if the indentation is huge like in the context of writing a template string inside of a nested block.

## Requirements

- Node
- NPM

## Installation

```bash
npm install indented
```

## Usage

```javascript
import { indented } from "indented"

const helloInFrench = "Salut"
const helloInEnglish = "Hello"

const codeElement = document.getElementById("javascript")

window.addEventListener("load", () => {
  if (codeElement instanceof HTMLElement) {
    codeElement.innerText = indented`
      <script>
        "use strict";
            
        if (window.navigator.language === "fr") {
          console.log("${helloInFrench}")
        } else {
          console.log("${helloInEnglish}")
        }
      </script>
    `
  }
})

```

Instead of this

```

      <script>
        "use strict";
            
        if (window.navigator.language === "fr") {
          console.log("${helloInFrench}")
        } else {
          console.log("${helloInEnglish}")
        }
      </script>
      
```

This library will output this

```
<script>
  "use strict";
      
  if (window.navigator.language === "fr") {
    console.log("${helloInFrench}")
  } else {
    console.log("${helloInEnglish}")
  }
</script>
```

---
_Source: https://npm.io/package/indented · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
