Search code examples
javascriptnode.jsassetsjsreport

jsReports assets nodejs


I am trying to add a css stylesheet as asset to a jsReport report.

  jsreport.render({
    template: {
      content: `

     
      <html>
      <link rel="stylesheet" type="text/css" href="/css/style.css">
          <head>
              <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
              <style>
                  {#asset /css/style.css}
              </style>
          </head>
          <body>
             ...
          </body>
      </html>

      `,
      
      engine: 'handlebars',
      recipe: 'html',
      assets: {
        allowedFiles: "static/**.js",
        publicAccessEnabled: true,
        searchOnDiskIfNotFoundInStore: true,
      },
    },
    data: newCart
  }).then((out) => {
    out.stream.pipe(res);
  }).catch((e) => {
    res.end(e.message);
  });

The problem is within the tags when I try to load the assets. Any idea on how to do this? Thanks in advance! :)


Solution

  • I "solved" the problem directly pasting the css in the tags as the issue was with the import of #asset.

    Not the best solution but it worked :)