1.0.6 • Published 4 years ago

rehype-partials v1.0.6

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

rehype-partials

Build Status Coverage Status

Partials support for rehype.

Usage

With the following html,

index.html
<div class='container'>
  <!-- href='include/hello.html' -->
</div>
./include/hello.html
<div class='hello'>
  <!-- href='world.html' -->
</div>
./include/world.html
<div class='world'>
  <p>world</p>
</div>

and the following js,

index.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>
  <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

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 © Paul Zimmer

1.0.6

4 years ago

1.0.5

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago