Passing beforeRender funtion in template



  • Hello,
    is it possible to send a "beforeRender" function as parameter in jsreport.render template?
    I put it in helpers but it didn't work.

    const helpers = "function beforeRender(req, res) { console.log('beforeRender from helper !!!!!!!!!!!!!!!!!!!!!!!!!!'); return; } "
     const result = await jsreport.render({
            template: {
                name: '/generic/generic-report',
                recipe: 'chrome-pdf',
                content: template,
                helpers: helpers
            },
           
        })
    
    

    Thank you so much!!!



  • Yes, see it in the docs

    https://jsreport.net/learn/scripts#api

    jsreport.render({
       template : {
          content: "foo",
          scripts: [{
              content: "async function beforeRender(req, res) { req.template.content='hello';  }"
          }]      
      }
    })
    


  • Thank you!!!
    Sorry, I didn't see it in the docs.
    Pablo


Log in to reply
 

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