mhr

metalsmith-hbs-relative-partial

A Metalsmith plugin to discover hbs partials relative to the template they are being used in

Showing:

Popularity

Downloads/wk

13

Maintenance

No Maintenance Data Available

Package

Dependencies

2

Size (min+gzip)

26.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Metalsmith HBS Relative Partial Plugin

Install: npm install metalsmith-hbs-realtive-partial

Purpose

Place Handlebars.js template partials in a directory relative to a view they are used in. Best used in conjunction with metalsmith-in-place.

Example

Given this structure...

/src
|    /about
|    |    /components
|    |    |    heading.hbs
|    index.hbs
...

With this content in heading.hbs...

<h1>Hello World</h1>

And this Handlebars partial usage in index.hbs...

{{> about/heading }}

Metalsmith will produce /about/index.html with this content...

<h1>Hello World</h1>

Initialize

In metalsmith.json:

{
  "plugins": {
    "metalsmith-hbs-relative-partial": {
      "dirName": "partials"
    }
  }
}
const relativePartial = require('metalsmith-hbs-relative-partial');
const inPlace = require('metalsmith-in-place');

require('metalsmith')(__dirname)
    .use(relativePartial({
        dirName: 'partials'
    }))
    .use(inPlace())
    .build()

dirName

The name of the directory that your partials will sit in. Example: 'components'... any partials nested under the source in a directory named 'components' will be registered with Handlebars. The name of the partial will be it's relative path to the area of the application. An aside.hbs partial in src/legal/components would be referred to like this: {{> legal/aside }}. Default: partials

License

MIT

Author

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100