Skip to content

htmlTemplate(options)

html
<title>{{ APP_TITLE }}</title>
ts
htmlTemplate({
	data: ({ mode }) => ({ APP_TITLE: mode === "production" ? "Fast" : "Fast Dev" }),
	strict: true,
});

Values are HTML-escaped by default. Unknown placeholders remain unless strict: true, which throws. Use escape: false only for fully trusted required raw markup.

htmlTemplate Template

Injects HTML template data and Vite HtmlTagDescriptor tags.

Signature

ts
export function htmlTemplate(options: HtmlTemplatePluginOptions): Plugin;

Example

ts
import { htmlTemplate } from "fast-vite-plugins";

const plugin = htmlTemplate({ data: { APP_TITLE: "Fast Admin" }, strict: true });

export default { plugins: [plugin] };

Input

InputTypeRequired / defaultDescription
optionsHtmlTemplatePluginOptionsRequiredTemplate data, extra tags, escaping, and strict settings.

Returns

ValueTypeDescription
pluginPluginHTML-template plugin for Vite plugins.