Hi guys, I was developing an app to generate an pp using puppeteer and express-handlebars, but i can't figure out how to compile the json and the template using express-handlebars.
const express = require('express');
const exphbs = require('express-handlebars');
const bodyParser = require('body-parser');
const path = require('path');
I also have a json file that i want to compile together and then use it in puppeteer:
app.get('/export/pdf', async (req, res) => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(html, data);
const buffer = await page.pdf({
format: 'A4',
printBackground: true
});
res.type('application/pdf');
res.send(buffer)
await browser.close()
I know how to do this using 'handlebars' only, but i didn't find how to do the same with express-handlebars.
Hi guys, I was developing an app to generate an pp using puppeteer and express-handlebars, but i can't figure out how to compile the json and the template using express-handlebars. const express = require('express'); const exphbs = require('express-handlebars'); const bodyParser = require('body-parser'); const path = require('path');
const app = express();
app.engine('hbs', exphbs({ defaultLayout: 'main', extname: '.hbs' })); app.set('view engine', 'hbs'); app.use(bodyParser.json()); app.use(express.static(path.join(__dirname, 'public')))
I also have a json file that i want to compile together and then use it in puppeteer: app.get('/export/pdf', async (req, res) => { try { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.setContent(html, data); const buffer = await page.pdf({ format: 'A4', printBackground: true }); res.type('application/pdf'); res.send(buffer) await browser.close()
I know how to do this using 'handlebars' only, but i didn't find how to do the same with express-handlebars.