@lighthousesystems/esbuild-plugin-handlebars
v1.0.0
Published
Handlebars.js plugin for esbuild
Downloads
1,452
Readme
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)