htmlTemplate(options)
html
<title>{{ APP_TITLE }}</title>ts
htmlTemplate({
data: ({ mode }) => ({ APP_TITLE: mode === "production" ? "Fast" : "Fast Dev" }),
strict: true,
});替换值默认进行 HTML 转义;未知占位符默认保留,strict: true 时会报错。只有完全可信且确实需要原始标记时才设置 escape: false。
htmlTemplate HTML模板
注入 HTML 模板数据与 Vite HtmlTagDescriptor 标签。
签名
ts
export function htmlTemplate(options: HtmlTemplatePluginOptions): Plugin;示例
ts
import { htmlTemplate } from "fast-vite-plugins";
const plugin = htmlTemplate({ data: { APP_TITLE: "Fast Admin" }, strict: true });
export default { plugins: [plugin] };输入
| 输入值 | 输入值类型 | 必填/默认值 | 输入值说明 |
|---|---|---|---|
options | HtmlTemplatePluginOptions | 是 | 模板数据、附加标签、转义与严格模式配置。 |
返回
| 返回值 | 返回值类型 | 返回值说明 |
|---|---|---|
plugin | Plugin | 可直接加入 Vite plugins 的 HTML 模板插件。 |
