# rollup-plugin-hbs

> Handlebars template bundle rollup plugin

Latest version **1.2.6** (published 2019-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-hbs
pnpm add rollup-plugin-hbs
yarn add rollup-plugin-hbs
bun add rollup-plugin-hbs
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2019-12-30 |
| First published | 2018-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yohan Gomez |
| Maintainers | yohangz |
| Keywords | rollup, rollup-plugin, handlebars, hbs, templating |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-hbs
- Repository: https://github.com/yohangz/rollup-plugin-hbs
- Homepage: https://github.com/yohangz/rollup-plugin-hbs#readme
- Issues: https://github.com/yohangz/rollup-plugin-hbs/issues
- npm.io page: https://npm.io/package/rollup-plugin-hbs

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.2.6 (latest) — 2019-12-30
- 1.2.5 — 2019-07-18
- 1.2.4 — 2019-06-18
- 1.2.3 — 2019-05-23
- 1.2.2 — 2019-01-24
- 1.2.1 — 2019-01-24
- 1.2.0 — 2018-11-07
- 1.1.0 — 2018-08-07
- 1.0.3 — 2018-06-29
- 1.0.2 — 2018-06-29
- 1.0.1 — 2018-06-29
- 1.0.0 — 2018-06-29

## README

<a href="https://travis-ci.org/yohangz/rollup-plugin-hbs">
    <img src="https://travis-ci.org/yohangz/rollup-plugin-hbs.svg?branch=master" alt="travis build" height="18">
</a>
<a href="https://github.com/yohangz/rollup-plugin-hbs/blob/master/LICENSE">
    <img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="license" height="18">
</a>  
<a href="https://badge.fury.io/js/rollup-plugin-hbs">
    <img src="https://badge.fury.io/js/rollup-plugin-hbs.svg" alt="npm version" height="18">
</a>

# rollup-plugin-hbs

Minimal handlebars template bundle rollup plugin based on [rollup-plugin-handlebars-plus][rollup-plugin-handlebars-plus]

## Installation

Via [Yarn](https://yarnpkg.com/lang/en/)

```yarn add rollup-plugin-hbs --save-dev```

Via [NPM](https://www.npmjs.com/)

```npm install rollup-plugin-hbs --save-dev```

## Usage

### Rollup Configuration

```js
// rollup.config.js
import hbs from 'rollup-plugin-hbs';

export default {
  entry: 'entry.js',
  dest: 'bundle.js',
  plugins: [
    hbs({
      handlebars: {
          // The module ID of the Handlebars runtime, exporting `Handlebars` as `default`.
          // As a shortcut, you can pass this as the value of `handlebars` above.
          // See the "Handlebars" section below.
        id: 'handlebars', // Default: the path of Handlebars' CJS definition within this module
        
          // Options to pass to Handlebars' `parse` and `precompile` methods.
        options: {
            // Whether to generate sourcemaps for the templates
          sourceMap: true // Default: true
        },
        
        // Whether to remove newline and whitespace characters from compiled output.
        optimize: true
      },
        
      // In case you want to compile files with other extensions.
      templateExtension: '.html', // Default: '.hbs'
        
      // A function that can determine whether or not a template is a partial.
      isPartial: (name) => name.startsWith('_') // Default: as at left
    })
  ]
}
```

### Usage in code

```html
{{! src/client/js/views/_messageBody.html }}
<p>{{message}}</p>
```

```html
{{! src/client/js/views/message.html }}
<div>{{> _messageBody }}</div>
```

```js
// main.js
import '_messageBody.html';
import MessageTemplate from 'message.html';

$('body').append(MessageTemplate({ message: 'Hello world!' }));
```

## License

This software is licensed under the [MIT][license] License

[license]: https://github.com/yohangz/rollup-plugin-hbs/blob/master/LICENSE
[rollup-plugin-handlebars-plus]: https://github.com/mixmaxhq/rollup-plugin-handlebars-plus

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