I Get [object Promise] from handlebars helper, when i use childTemplate.call()

  • Since a few days i play around with jsReport to see if we could use it. And I am seriously stoked about it.
    It could become a serious competitor for jasperreports for us.

    I want to pass the content (innerhtml) of the whole handlebar to a child template and use it there. Only I don't have a working idea how to make this work.


  • Okay, I found the solution myself.

    function notificationTemplate(name, title, color, opts) {
        return childTemplate.call({
                // add extra param
                data: {
                    innerhtml: (typeof opts.fn == 'function') ? opts.fn(this) : 
                               (typeof opts.inverse == 'function') ? opts.inverse(this) : 
            }, {
                recipe: "html",
                engine: "handlebars",
        }, opts)

    Only I have no idea what the opts.fn(this) or opts.inverse(this) is supposed to be.
    But it works.

  • I' m glad you like what we do.

    The opts.fn evaluate handlebars inside the block helper and returns a string. The opts.inverse does the same, but for the block you put into the {{else}} section.

    Your solution looks good, you can even go just with
    innerhtml: opts.fn(this)

Log in to reply

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