Async function won't show component call
-
We have a report which contains more or less an "optional" component template. If the template exists on a specific path we print it, if not, we don't want to get an error in the report
throw new Error(``Component ${path} not found``)
Therefore we created a handlebar conditional which returns the
options.fn(this)
if the template is found and we call thecomponent
helper to print the component.
Up to jsreport 4.2.x this just worked fine and the component content was printed, since jsreport 4.3.0 the component block just returns a string (I guess an object reference).{{#componentExists "./components/student"}} {{component "./components/student" classRoomDetail=(findClassRoomDetail classRoom)}} {{/componentExists}}
const jsreport = require('jsreport-proxy'); async function componentExists(componentName, options) { const component = await jsreport.folders.resolveEntityFromPath(componentName, 'components'); return component ? options.fn(this): options.inverse(this); }
I'm thankful for any advice why this is happening and/or how the original behavior can be recreated (printing the component content).
Here's a running example of our report setup. The works in jsreport 4.2.x
https://playground.jsreport.net/w/ThomasJReiter/~ejVYSVP
-
Thank you for verbose sharing of the problem.
This looks like a regression issue in the 4.3.0. We will discuss how to deal with it and come back here shortly.
Unfortunately, I don't see a good workaround, rather keep the downgraded version that works for you.
I apologize for the inconvenience.
-
Hi Jan,
Any update on this?
-
We have it fixed and planning the release likely during the next days.
-
Great news, many thanks...