1.2.6 • Published 4 years ago

rollup-plugin-hbs v1.2.6

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

rollup-plugin-hbs

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

Installation

Via Yarn

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

Via NPM

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

Usage

Rollup Configuration

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

{{! src/client/js/views/_messageBody.html }}
<p>{{message}}</p>
{{! src/client/js/views/message.html }}
<div>{{> _messageBody }}</div>
// 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

1.2.6

4 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago