Missing Helper



  • I have seen this issue discussed and resolved in other posts but I have tried everything that I have read and I am still getting the error Error occured - Error during rendering report: Missing helper: "isnt"
    I have a global_helpers.js asset created with the shared helpers attached to each template checked.
    The content of my global_helpers.js is as follows:

    var handlebars = require('handlebars');
    var HandlebarsIntl = require('handlebars-intl');
    HandlebarsIntl.registerWith(handlebars);
    var helpers = require('handlebars-helpers')({ handlebars: handlebars });
    

    My template is as follows: (engine: handlebars, recipe: html)

    {{#isnt 'foo' 'bar'}}Some random text{{/isnt}}
    

    When I try to run this, I get the following error:

    Error occured - Error during rendering report: Missing helper: "isnt"
    Stak - /Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19
          throw new _exception2['default']('Missing helper: "' + arguments[arguments.length - 1].name + '"');
          ^
    
    Error: Missing helper: "isnt"
        at Object.<anonymous> (/Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13)
        at Object.eval [as main] (eval at createFunctionContext (/Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:5:88)
        at main (/Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32)
        at ret (/Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12)
        at ret (/Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21)
        at /Users/charlie/Code/jsreport/node_modules/jsreport-handlebars/lib/handlebarsEngine.js:25:14
        at evalmachine.<anonymous>:1:41
        at ContextifyScript.Script.runInContext (vm.js:59:29)
        at ContextifyScript.Script.runInNewContext (vm.js:65:15)
        at Object.runInNewContext (vm.js:135:38)
    

    Then strange thing is that this was working yesterday and just stopped working today.
    Any thoughts?

    Thanks,
    Charlie



  • Actually, I think I may have figured this one out but not sure. If I remove the first line var handlebars = require('handlebars'); in the global_helpers.js it appears to work again. I think this is because there is a handlebars var already exposed globally and the code I have above is overwriting it and attaching the helpers to the new instance.



  • That does appear to fix the issue. Not sure why this just started happening.
    If this in fact the solution, I think the tip/howto on at the bottom of https://jsreport.net/learn/handlebars might need to be updated.


  • administrators

    thanks for the letting us knowm, we will see what is happening and update the docs if needed, maybe it is jus a special behaviour with global helpers and needs a new section in docs.


Log in to reply
 

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