# rehype-partials

> Partials support for rehype

Latest version **1.0.6** (published 2020-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install rehype-partials
pnpm add rehype-partials
yarn add rehype-partials
bun add rehype-partials
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-04-03 |
| First published | 2019-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Paul Zimmer |
| Maintainers | mrzmmr |
| Keywords | rehype, unified, html, partials, templates |

## Links

- npm: https://www.npmjs.com/package/rehype-partials
- Repository: https://github.com/mrzmmr/rehype-partials
- Homepage: https://github.com/mrzmmr/rehype-partials#readme
- Issues: https://github.com/mrzmmr/rehype-partials/issues
- npm.io page: https://npm.io/package/rehype-partials

## Dependencies (2)

- [unified](https://npm.io/package/unified.md) ^8.3.2
- [rehype-parse](https://npm.io/package/rehype-parse.md) ^6.0.1

## 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

- 1.0.6 (latest) — 2020-04-03
- 1.0.5 — 2019-12-10
- 1.0.3 — 2019-07-25
- 1.0.2 — 2019-07-17
- 1.0.1 — 2019-06-05
- 1.0.0 — 2019-03-25

## README

# rehype-partials

[![Build Status](https://travis-ci.org/mrzmmr/rehype-partials.svg?branch=master)](https://travis-ci.org/mrzmmr/rehype-partials)
[![Coverage Status](https://coveralls.io/repos/github/mrzmmr/rehype-partials/badge.svg?branch=master)](https://coveralls.io/github/mrzmmr/rehype-partials?branch=master)

Partials support for [rehype].

## Usage

With the following html,

##### index.html

```html
<div class='container'>
  <!-- href='include/hello.html' -->
</div>
```

##### ./include/hello.html

```html
<div class='hello'>
  <!-- href='world.html' -->
</div>
```

##### ./include/world.html

```html
<div class='world'>
  <p>world</p>
</div>
```

and the following js,

##### index.js

```js
var reporter = require('vfile-reporter')
var format = require('rehype-format')
var vfile = require('to-vfile')
var rehype = require('rehype')
var partials = require('rehype-partials')

rehype()
  .use(partials)
  .use(format)
  .process(toVfile.readSync('./index.html'), function (err, file) {
    console.error(reporter(err || file))
    console.log(String(file))
  })
```

will output:

```
./index.html: no issues found
```

```html
<html>
  <head></head>
  <body>
    <div class="container">
      <div class="hello">
        <div class="world">
          <p>world</p>
        </div>
      </div>
    </div>
  </body>
</html>
```

## Options

### `options.handle`

*Type: `function`*

*Default: `fs.readFile`*

Function used to get a partial. [example][handle-example]


### `options.cwd`

*Type: `String`*

*Default: `''`*

Set the current working directory to resolve a partial's path.


### `options.noresolve`

*Type: `Boolean`*

*Default: `false`*

Whether or not to use `path.resolve` when looking for a partial.


### `options.messages`

*Type: `Boolean`*

*Default: `true`*

Whether to include messages generated when parsing a partial.


## License

[MIT][license] © Paul Zimmer

[rehype]: https://github.com/rehypejs/rehype
[handle-example]: https://github.com/mrzmmr/rehype-partials/tree/master/examples/custom-handle
[license]: https://github.com/mrzmmr/rehype-partials/blob/master/license

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