How to add Handlebars helpers in dotnet ?



  • I am just using the jsreport for making simple pdf report. At the moment my code like this

        [HttpGet("test")]
        public async  Task<IActionResult> Test(){
            var sdr = await _appRepository.GetStaffDefaultRates();  
            var dto  = _mapper.Map<List<StaffDefaultRate>, List<StaffDefaultRateReportDto>>(sdr);          
            var x = new {
                bootstrapcss = "http://localhost:5000/public/css/bootstrap.min.css",
                publicPath = "http://localhost:5000/public/",
                message = "hello world",
                today = DateTime.Now.ToString("dd MMM yyyy"),
                staffRates = dto,
            };
            var staffRates = _fileRepository.ReadReportTemplate("StaffRates.html");
            var rs = new ReportingService("http://localhost:5488");
            var report = await rs.RenderAsync(new RenderRequest(){
                Template = new Template(){
                    Recipe = Recipe.ChromePdf,
                    Engine = Engine.Handlebars,
                    Content = staffRates,
                }, Data = x 
            }); 
            var memory = new MemoryStream();
            await report.Content.CopyToAsync(memory);
            memory.Position = 0 ;
            return File(memory, "application/pdf");
            // return Ok(staffRates);
        }
    

    So I use file to store template and send it to server to generate pdf. Now I need to format date in my templates and I am going to use moment.js to do that.

    How do I attach the helpers.js and moment.js as well into my report ?



  • This is a duplicated question of the one asked on StackOverflow. I answered it there.
    https://stackoverflow.com/questions/58851407/how-to-include-helpers-in-jsreport/58883252#58883252

    Please don't post questions duplicates. Choose forum or so, what you prefer, and ask just once.


Log in to reply
 

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