Missing helper: "asset" (jsreport-core)
-
Hi everyone!
I'm new to jsreport and I wanted to generate a pdf report using handlebars with some assets (styles.css and an image) locally, using jsreport-core. If I run this on the studio, I get the pdf rendered perfectly:
However, when I have the exact template and data on my application and I try to render it, I get the following error:
2022-09-28T16:11:06.946Z - info: Render request 1 queued for execution and waiting for available worker fromEmitProfile=true, rootId=szklhvremsrqay4, id=szklhvremsrqay4
2022-09-28T16:11:07.309Z - info: Starting rendering request 1 (user: null) rootId=szklhvremsrqay4, id=szklhvremsrqay4, fromEmitProfile=true
2022-09-28T16:11:07.311Z - info: Rendering anonymous template { recipe: chrome-pdf, engine: handlebars } rootId=szklhvremsrqay4, id=szklhvremsrqay4, fromEmitProfile=true
2022-09-28T16:11:07.312Z - debug: Rendering engine handlebars rootId=szklhvremsrqay4, id=szklhvremsrqay4, fromEmitProfile=true
2022-09-28T16:11:08.131Z - warn: Error when processing render request 1 Error when evaluating engine handlebars for template anonymousMissing helper: "asset"(sandbox.js line 13:18) Error: Missing helper: "asset"
The version I'm running is 3.7.1, so it shouldn't have to be related with the old sintax {#asset} right?
I will show the structure of my application below.My project structure looks like this:
To initialize jsreport, I do:
As far as I know, with that asset config jsreport should find the assets locally right?
Then, to get the content and data, I just read the files. The render looks like this:
Btw, if I do this without any assets (only data), I works perfectly.
Do you have any idea of what I could be missing? I've been troubleshooting this for days and I can't figure it out.I really appreciate your help!
-
You need to
.use
also the@jsreport/jsreport-asset
module.
-
Hi Jan! Thanks for the quick response.
I've tried this
but it says Cannot find module.
Any idea?
-
Sorry, typo. It should be
jsreport-assets