Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yohangz/rollup-plugin-hbs
Handlebars template bundle rollup plugin
https://github.com/yohangz/rollup-plugin-hbs
handlebars plugin rollup templating
Last synced: 3 months ago
JSON representation
Handlebars template bundle rollup plugin
- Host: GitHub
- URL: https://github.com/yohangz/rollup-plugin-hbs
- Owner: yohangz
- License: mit
- Created: 2018-06-29T12:50:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T22:16:45.000Z (almost 3 years ago)
- Last Synced: 2024-09-16T10:46:15.080Z (5 months ago)
- Topics: handlebars, plugin, rollup, templating
- Language: JavaScript
- Size: 163 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 }}{{message}}
``````html
{{! src/client/js/views/message.html }}{{> _messageBody }}
``````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