Handlebars.js plugin for esbuild
npm install @lighthousesystems/esbuild-plugin-handlebars
A handlebars template precompiler for esbuild.
npm i esbuild-plugin-handlebars --save-dev
``javascript
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: {}
})
]
});
`
`javascript`
import template from "template.hbs";
// => returns template.hbs content as a template function
Helpers must be provided as options to the plugin.
It is unknown whether external partials work.
- filter: the filenames that will be processed by this plugin. Defaults to files with the extensions .hbs or .handlebars.hb.precompile()` call.
- additionalHelpers: the helpers that can be used in templates.
- precompileOptions: options passed into the
See the CHANGELOG.md file.
MIT (http://www.opensource.org/licenses/mit-license)