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:
    0_1664382138793_upload-2f43ed04-72f9-4045-afda-dae549c3ce4b

    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:
    0_1664381992695_upload-bc75929d-3b4c-4754-967b-e2d081e43ae3

    To initialize jsreport, I do:
    0_1664382468300_upload-22c05269-933d-4f09-8d43-720d5a067a1f

    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:
    0_1664382830854_upload-4f920053-a6ba-4311-891a-ddcee08ea7bf

    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
    0_1664467070964_upload-46eb062f-a70a-4685-b105-28d5486f7df2

    but it says Cannot find module.
    0_1664466983519_upload-9a014a02-9a49-48af-ac9b-b67cfa2e0c3d

    Any idea?



  • Sorry, typo. It should be jsreport-assets


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.