Image not rendering in jsreport 2.5 with pug/electron-pdf
-
Hello, we upgraded from 1.9.2 (with jade and electron-pdf) to 2.5 (switched to pug and electron-pdf) recently and our images are no longer rendering. We have dynamic base64 strings that are placed into image tags. Here is a snippet of the template:
if (frontMatterPages) each frontMatterPage in frontMatterPages .page .page-header .page-content(style="text-align: center") br br if frontMatterPage.base64 img(src="data:image/png;base64, #{frontMatterPage.base64}" width="95%" height="auto")
I made an example in the sandbox. The base64 string is the same, but when used as a variable it doesn't work:
https://playground.jsreport.net/w/fizzofdeath/gKHp3D6YIn the example, the first image does not render, but the second does. Is there some syntax change that I'm missing to put variables in the image tag?
Thanks!
-
i think pug no longer replaces variables inside strings in that way, it needs some ES6 string interpolation, basically change it to:
src=`data:image/png;base64, ${frontMatterPage.base64}`
same example but now working with the syntax change: https://playground.jsreport.net/w/bjrmatos/33yMpcNG
-
Oh thanks! I did not manage to search for the right thing to get the string interpolation info. I appreciate your time!