MCPcopy Index your code
hub / github.com/ProNextJS/declarative-routing / buildStringFromTemplate

Function buildStringFromTemplate

src/template.ts:8–22  ·  view source on GitHub ↗
(
  templatePath: string,
  data: unknown
)

Source from the content-addressed store, hash-verified

6const templates: Record<string, HandlebarsTemplateDelegate<any>> = {};
7
8export async function buildStringFromTemplate(
9 templatePath: string,
10 data: unknown
11) {
12 if (!templates[templatePath]) {
13 const __filename = fileURLToPath(import.meta.url);
14 const __dirname = path.dirname(__filename);
15 let contents = fs
16 .readFileSync(path.resolve(__dirname, `../assets/${templatePath}`))
17 .toString();
18
19 templates[templatePath] = Handlebars.compile(contents);
20 }
21 return templates[templatePath](data);
22}
23
24export async function buildFileFromTemplate(
25 templatePath: string,

Callers 3

writeRoutesFunction · 0.90
writeOpenAPIFunction · 0.90
buildFileFromTemplateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected