Class HandlebarsJs


  • @Deprecated(since="2022-05-05")
    public abstract class HandlebarsJs
    extends Object
    Deprecated.
    com.github.jknack.handlebars.js package is deprecated and marked for removal in subsequent upgrades for handlebars.
    The main motivation of HandlebarsJs is the ability of reuse JavaScript helpers in the server and the client.
    Since:
    1.1.0
    • Method Detail

      • registerHelpers

        public abstract void registerHelpers​(String filename,
                                             String source)
                                      throws Exception
        Deprecated.

        Register helpers from a JavaScript source.

        A JavaScript source file looks like:

          Handlebars.registerHelper('hey', function (context) {
            return 'Hi ' + context.name;
          });
          ...
          Handlebars.registerHelper('hey', function (context, options) {
            return 'Hi ' + context.name + options.hash['x'];
          });
          ...
          Handlebars.registerHelper('hey', function (context, p1, p2, options) {
            return 'Hi ' + context.name + p1 + p2 + options.hash['x'];
          });
          ...
         
        To keep your helpers reusable between server and client avoid DOM manipulation.
        Parameters:
        filename - The file name (just for debugging purpose). Required.
        source - The JavaScript source. Required.
        Throws:
        Exception - If the JavaScript helpers can't be registered.
      • createRhino

        public static HandlebarsJs createRhino​(HelperRegistry helperRegistry,
                                               int optimizationLevel)
        Deprecated.
        Creates a HandlebarsJs object.
        Parameters:
        helperRegistry - The helperRegistry object. Required.
        optimizationLevel - The optimization level of rhino.
        Returns:
        A new HandlebarsJs object.