1153a4f7a1
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
17 lines
565 B
TypeScript
17 lines
565 B
TypeScript
// server/templates/render.ts
|
|
import Mustache from "mustache";
|
|
import { readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
const TEMPLATES_ROOT = resolve(process.cwd(), "templates");
|
|
|
|
export interface TemplateVars {
|
|
aptProxy?: string | null;
|
|
}
|
|
|
|
export function renderTemplate(relPath: string, vars: TemplateVars): string {
|
|
const tpl = readFileSync(resolve(TEMPLATES_ROOT, relPath), "utf8");
|
|
// Mustache échappe le HTML par défaut; on désactive (ce sont des scripts shell).
|
|
return Mustache.render(tpl, vars, {}, { escape: (s) => s });
|
|
}
|