Now formatting currency ans distance

ref #36
This commit is contained in:
2021-03-31 16:24:05 +02:00
parent 1d12de7045
commit e0add846bb
2 changed files with 18 additions and 6 deletions

View File

@@ -98,6 +98,18 @@ export class PdfCreator {
return config.sponor_logos[index];
}
);
await Handlebars.registerHelper('--format_kilometers',
function (str) {
let meters = parseInt(str);
return ((meters / 1000).toFixed(3).toString())
}
);
await Handlebars.registerHelper('--format_currency',
function (str) {
let meters = parseInt(str);
return ((meters / 100).toFixed(2).toString())
}
);
this.browser = await puppeteer.launch({ headless: true, args: minimal_args });
}
@@ -179,7 +191,7 @@ export class PdfCreator {
await i18next.changeLanguage(locale);
const template_source = fs.readFileSync(`${this.templateDir}/runner_certificate.html`, 'utf8');
const template = Handlebars.compile(template_source);
let result = template({ runners, eventname: config.eventname });
let result = template({ runners, eventname: config.eventname, currency_symbol: config.currency_symbol });
result = await awaitAsyncHandlebarHelpers(result);
const pdf = await this.renderPdf(result, { format: "A4", landscape: false, printBackground: true });
return pdf;