UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

24 lines (23 loc) 920 B
import fs from "@reliverse/relifso"; import { relinka } from "@reliverse/relinka"; import handlebars from "handlebars"; import path from "node:path"; export async function processTemplate(srcPath, destPath, context) { try { const templateContent = await fs.readFile(srcPath, "utf-8"); const template = handlebars.compile(templateContent); const processedContent = template(context); await fs.ensureDir(path.dirname(destPath)); await fs.writeFile(destPath, processedContent); } catch (error) { relinka("error", `Error processing template ${srcPath}:`, error); throw new Error(`Failed to process template ${srcPath}`); } } handlebars.registerHelper("eq", (a, b) => a === b); handlebars.registerHelper("and", (a, b) => a && b); handlebars.registerHelper("or", (a, b) => a || b); handlebars.registerHelper( "includes", (array, value) => Array.isArray(array) && array.includes(value) );