public abstract class HandlebarsJs
extends java.lang.Object
HandlebarsJs
is the ability of reuse JavaScript helpers in the
server and the client.Constructor and Description |
---|
HandlebarsJs(HelperRegistry helperRegistry)
Creates a new
HelperRegistry object. |
Modifier and Type | Method and Description |
---|---|
static HandlebarsJs |
create(HelperRegistry helperRegistry)
Creates a
HandlebarsJs object. |
static HandlebarsJs |
createRhino(HelperRegistry helperRegistry,
int optimizationLevel)
Creates a
HandlebarsJs object. |
abstract void |
registerHelpers(java.lang.String filename,
java.lang.String source)
Register helpers from a JavaScript source.
|
public HandlebarsJs(HelperRegistry helperRegistry)
HelperRegistry
object.helperRegistry
- The HelperRegistry
instance. Required.public abstract void registerHelpers(java.lang.String filename, java.lang.String source) throws java.lang.Exception
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.
filename
- The file name (just for debugging purpose). Required.source
- The JavaScript source. Required.java.lang.Exception
- If the JavaScript helpers can't be registered.public static HandlebarsJs create(HelperRegistry helperRegistry)
HandlebarsJs
object.helperRegistry
- The helperRegistry object. Required.HandlebarsJs
object.public static HandlebarsJs createRhino(HelperRegistry helperRegistry, int optimizationLevel)
HandlebarsJs
object.helperRegistry
- The helperRegistry object. Required.optimizationLevel
- The optimization level of rhino.HandlebarsJs
object.Copyright © 2010 - 2020 Adobe. All Rights Reserved