Search code examples
handlebars.jshelperview-helpershapi.js

Is there a way to integrate handlebars-helpers with hapi?


I would like to use the handlebars-helpers node module with my handlebars templates. I'm using hapi as my framework which supports handlebars. I haven't found any documentation or examples that shows how to use handlebars-helpers with hapi using handlebars as the view engine.

Is it possible and if so, what is the solution?


Solution

  • I don't think it's currently possible according to hapijs api docs for views:

    http://hapijs.com/api#serverviewsoptions

    helpersPath - the directory path where helpers are located. Helpers are functions used within templates to perform transformations and other data manipulations using the template context or other inputs. Each '.js' file in the helpers directory is loaded and the file name is used as the helper name. The files must export a single method with the signature function(context) and return a string. Sub-folders are not supported and are ignored. Defaults to no helpers support (empty path). Note that jade does not support loading helpers this way.

    Looks as though handlebars-helpers has a different signature than what is required by hapi