# proper-tags

> A few common utility template tags for ES2015

Latest version **2.0.2** (published 2023-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install proper-tags
pnpm add proper-tags
yarn add proper-tags
bun add proper-tags
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2023-08-25 |
| First published | 2023-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 69.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Hexagon |
| Maintainers | hexagon |
| Keywords | array, babel, es2015, es2015-tag, es6, es6-tag, heredoc, html, indent, indents, line, literal, multi, multiline, normalize, one, oneline, single, singleline, string, strings, strip, tag, tagged, template |

## Links

- npm: https://www.npmjs.com/package/proper-tags
- Repository: https://github.com/hexagon/proper-tags
- Issues: http://github.com/declandewet/common-tags/issues
- npm.io page: https://npm.io/package/proper-tags

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2023-08-25
- 2.0.1 — 2023-06-18
- 2.0.0-beta.0 — 2023-03-30
- 2.0.0-alpha.5 — 2023-03-29
- 2.0.0-alpha.4 — 2023-03-29
- 2.0.0-alpha.3 — 2023-03-29
- 2.0.0-alpha.2 — 2023-03-29
- 2.0.0-alpha.1 — 2023-03-29
- 2.0.0-alpha.0 — 2023-03-29

## README

# proper-tags (common-tags rebooted)

[![npm version](https://badge.fury.io/js/proper-tags.svg)](https://badge.fury.io/js/proper-tags) [![NPM Downloads](https://img.shields.io/npm/dw/proper-tags.svg)](https://www.npmjs.org/package/proper-tags)
![No dependencies](https://img.shields.io/badge/dependencies-none-brightgreen) [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Hexagon/proper-tags/blob/master/LICENSE)

**proper-tags** is an evolved version of the widely-used CommonJS package **common-tags**. It has been updated with the following considerations for modern JavaScript environments:

* 🌟 Extendable: proper-tags comes with built-in tools for creating custom tags.
* 📦 ESM Code Base: With support for ESM/ECMAScript Modules, it ensures native compatibility with modern development tools.
* 🦕 Deno Compatibility: Designed specifically to function seamlessly with the Deno runtime.
* 📝 TypeScript Definitions: Integrated TypeScript typings make development in TypeScript a breeze.
* 🔄 API Consistency: Its interface aligns with common-tags, ensuring compatibility with existing frameworks and guides.

Below is a quick guide, check out the full documentation at [https://proper-tags.56k.guru](https://proper-tags.56k.guru).

## Quick Example

```js
import { html } from 'proper-tags';

html`
  <div id="user-card">
    <h2>${user.name}</h2>
  </div>
`
```
## Installation

### Node

Install

```js
npm install proper-tags
```

ESM Import:

```js
import { stripIndent } from 'proper-tags';
```

Legacy CommonJS Require:

```js
const { stripIndent } = require('proper-tags');
```

### Deno 

To use `proper-tags` with **Deno**, import it from deno.land:

```js
import { html } from 'https://deno.land/x/proper_tags/dist/proper-tags.js';
```

> **Note:** Make sure to freeze the url to a specific version

### CDN/Browser

To include proper-tags via **jsdelivr**, add the following script tag to your HTML file:

```html
<script src="https://cdn.jsdelivr.net/npm/proper-tags@2.0.2/dist/proper-tags.umd.js"></script>
```

> **Note:** Make sure to replace `2.0.2` with the latest version


## Usage

### Imports

Like all ES modules, `proper-tags` begins with an `import`.

```js
import { stripIndent } from 'proper-tags'
```

### Available Functions

* `html`: Properly indents arrays and newline characters in string substitutions.
   * Aliases: `source`, `codeBlock`
* `safeHtml`: Similar to html, but with safe HTML escaping for strings.
* `oneLine`: Converts multi-line strings into a single line.
* `oneLineTrim`: Converts multi-line strings into a single line, trimming newlines.
* `stripIndent`: Strips the initial indentation from the beginning of each line in a multiline string.
* `stripIndents`: Strips all indentation from the beginning of each line in a multiline string.
* `inlineLists`: Inlines an array substitution as a list.
* `oneLineInlineLists`: Inlines an array substitution as a list, rendered on a single line.
* `commaLists`: Inlines an array substitution as a comma-separated list.
* `commaListsOr`: Inlines an array as a comma-separated list, with the last item prefixed by "or".
* `commaListsAnd`: Inlines an array as a comma-separated list, with the last item prefixed by "and".
* `oneLineCommaLists`: Inlines an array as a comma-separated list on a single line.
* `oneLineCommaListsOr`: Inlines an array as a comma-separated list on a single line, with the last item prefixed by "or".
* `oneLineCommaListsAnd`: Inlines an array as a comma-separated list on a single line, with the last item prefixed by "and".
* `id`: A no-op tag useful in scenarios like mocking.

For more information, examples, functions for advanced usage and best practices, refer to the documentation at [proper-tags.56k.guru](https://proper-tags.56k.guru).

## How to Contribute

Please see the [Contribution Guidelines](https://proper-tags.56k.guru/contributing.html).

## License

MIT. See [license](https://proper-tags.56k.guru/license.html).

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