mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-01 20:28:17 +00:00
18 lines
488 B
TypeScript
18 lines
488 B
TypeScript
import { readFileSync } from 'fs';
|
|
import Handlebars from 'handlebars';
|
|
import { Parser } from './parser.interface';
|
|
|
|
export class HtmlParser<T> implements Parser<T> {
|
|
constructor(private readonly templatePath: string) {}
|
|
async parse(data: T[]) {
|
|
const templateSource = readFileSync(this.templatePath, 'utf8');
|
|
|
|
const template = Handlebars.compile(templateSource);
|
|
|
|
return template({
|
|
dados: data,
|
|
dataGeracao: new Date().toLocaleString('pt-BR'),
|
|
});
|
|
}
|
|
}
|