@@ -1,8 +1,11 @@
|
||||
import fs from "fs";
|
||||
import Handlebars from 'handlebars';
|
||||
import i18next from "i18next";
|
||||
import Backend from 'i18next-fs-backend';
|
||||
import path from 'path';
|
||||
import puppeteer from "puppeteer";
|
||||
import { Runner } from './models/Runner';
|
||||
import Handlebars = require('handlebars');
|
||||
|
||||
/**
|
||||
* This class is responsible for all things pdf creation.
|
||||
* This uses the html templates from src/templates.
|
||||
@@ -12,12 +15,25 @@ export class PdfCreator {
|
||||
private browser;
|
||||
|
||||
constructor() {
|
||||
i18next
|
||||
.use(Backend)
|
||||
.init({
|
||||
fallbackLng: 'en',
|
||||
lng: 'en',
|
||||
backend: {
|
||||
loadPath: path.join(__dirname, '/locales/{{lng}}.json')
|
||||
}
|
||||
});
|
||||
Handlebars.registerHelper('__',
|
||||
function (str) {
|
||||
return i18next.t(str).toString();
|
||||
}
|
||||
);
|
||||
puppeteer.launch({ headless: true }).then(browser => {
|
||||
this.browser = browser;
|
||||
});
|
||||
}
|
||||
|
||||
//TODO: Accept the runner class
|
||||
public async generateSponsoringContract(runner: Runner): Promise<any> {
|
||||
const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8');
|
||||
const template = Handlebars.compile(template_source);
|
||||
|
||||
Reference in New Issue
Block a user