( templatePath: string, data: unknown )
| 6 | const templates: Record<string, HandlebarsTemplateDelegate<any>> = {}; |
| 7 | |
| 8 | export 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 | |
| 24 | export async function buildFileFromTemplate( |
| 25 | templatePath: string, |
no outgoing calls
no test coverage detected