# 集成

以下软件包将 Handlebars 集成到不同的环境中。这些软件包**没有**得到 Handlebars 团队的官方支持。

有多个 webpack 插件允许您在 Webpack 环境中使用 Handlebars。

# Webpack: handlebars-loader

The handlebars-loader (在新窗口中打开) 允许您导入 预编译 模板。只需将您的 handlebars 模板写入 template.handlebars 文件,并使用以下方法导入它:

const compiledTemplate = require("./template.handlebars");

import compiledTemplate from "./template.handlebars";

# Webpack: handlebars-webpack-plugin

The handlebars-webpack-plugin (在新窗口中打开) 使用 Handlebars 在编译应用程序时静态构建您的 HTML 页面。

# Webpack: html-bundler-webpack-plugin

The html-bundler-webpack-plugin (在新窗口中打开) 使用各种模板引擎,包括 Handlebars (在新窗口中打开),来渲染模板并将样式和脚本捆绑到生成的 HTML 中。

# Babel: handlebars-inline-precompile

The babel-plugin-handlebars-inline-precompile (在新窗口中打开) 预编译作为 JavaScript 源代码中的模板文字提供的 Handlebars 模板。

import hbs from "handlebars-inline-precompile";
const compiledTemplate = hbs`{{name}}`;

有关设置说明,请参阅软件包的文档。

# Browserify: hbsfy

The hbsfy (在新窗口中打开) 软件包允许您在 browserify 环境中导入预编译模板。

const compiledTemplate = require("./template.handlebars");

# Parcel: parcel-plugin-handlebars

有一个旧的 parcel 插件:https://npmjs.net.cn/package/parcel-plugin-handlebars

但您应该使用该软件包的众多分支之一,这些分支更新:https://npmjs.net.cn/search?q=parcel-plugin-handlebars

最新的是:https://npmjs.net.cn/package/@inventory/parcel-plugin-handlebars

# Parcel: parcel-plugin-handlebars-precompile

TODO: 在这里写文字

https://npmjs.net.cn/package/parcel-plugin-handlebars-precompile

最后更新时间: 2023 年 8 月 5 日 下午 1:00:37