@lighthousesystems/esbuild-plugin-handlebars
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

latest version

esbuild-plugin-handlebars

A handlebars template precompiler for esbuild.

Installation

npm i esbuild-plugin-handlebars --save-dev

General Usage

esbuild configuration

import hbsPlugin from "esbuild-plugin-handlebars";

esbuild.build({
    entryPoints: ["index.ts"],
    ...
    plugins: [
        hbsPlugin({
            filter: /\.(hbs|handlebars)$/i,
            additionalHelpers: {
                toLowerCase: "templateHelpers/toLowerCase",
                translate: "templateHelpers/translate"
            },
            precompileOptions: {}
        })
    ]
});

Your JS making use of the templates

import template from "template.hbs";
// => returns template.hbs content as a template function

Details

Helpers must be provided as options to the plugin. It is unknown whether external partials work.

Options

  • filter: the filenames that will be processed by this plugin. Defaults to files with the extensions .hbs or .handlebars.
  • additionalHelpers: the helpers that can be used in templates.
  • precompileOptions: options passed into the hb.precompile() call.

Change Log

See the CHANGELOG.md file.

License

MIT (http://www.opensource.org/licenses/mit-license)

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @lighthousesystems/esbuild-plugin-handlebars

    Weekly Downloads

    325

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.05 kB

    Total Files

    5

    Last publish

    Collaborators

    • smenus
    • brandscill
    • rossmuego