Parse Error with docximage when getting src with #asset



  • I'm trying to get an Image from Assets into my docx Templated report therefor I'm using the following Tags on the image link: {{docxImage src={#asset test2.jpg @encoding=dataURI}}} However this results in some strange parsing Error:

    Error: Error while executing docx recipe. Error while executing templating engine. Parse error on line 5:
    ...mage src=data:image/jpeg;base64,/9j/4AAQ
    -----------------------^
    Expecting 'ID', got 'INVALID'
        at module.exports (D:\gitProjects\jsreport\node_modules\jsreport-core\lib\util\createError.js:11:13)
        at Reporter.createError (D:\gitProjects\jsreport\node_modules\jsreport-core\lib\reporter.js:332:12)
        at Object.execute (D:\gitProjects\jsreport\node_modules\jsreport-docx\lib\recipe.js:58:20)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async module.exports (D:\gitProjects\jsreport\node_modules\jsreport-core\lib\render\render.js:150:5)
    caused by: Error: Error while executing templating engine. Parse error on line 5:
    ...mage src=data:image/jpeg;base64,/9j/4AAQ
    -----------------------^
    Expecting 'ID', got 'INVALID'
        at Object.callbackRequests.<computed> (D:\gitProjects\jsreport\node_modules\script-manager\lib\worker-servers.js:250:31)
        at process.<anonymous> (D:\gitProjects\jsreport\node_modules\script-manager\lib\worker-servers.js:195:30)
        at process.emit (events.js:412:35)
        at process.emit (domain.js:470:12)
        at emit (internal/child_process.js:910:12)
        at processTicksAndRejections (internal/process/task_queues.js:83:21)
    

  • administrators

    hi @Marsturix did you tried to use " i mean, you should update the call to be {{docxImage src="{#asset test2.jpg @encoding=dataURI}" }}. when the value passed to handlebars option is a raw value, you should wrap it with the string literal characters "



  • @bjrmatos Ah thank you. With {{docxImage src="{#asset test2.jpg @encoding=dataURI}" }} it worked.

    could I have found this in the documentation somewhere?


  • administrators

    I agree that it is a bit confusing but I believe this is handlebars specific knowledge and our docs are not the best place to explain it, there are lot of handlebars references in the docs and adding explanation of the syntax will be overwhelming


Log in to reply
 

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