public class DefaultHelperRegistry extends java.lang.Object implements HelperRegistry
HelperRegistry
.HELPER_MISSING
Constructor and Description |
---|
DefaultHelperRegistry() |
Modifier and Type | Method and Description |
---|---|
Decorator |
decorator(java.lang.String name)
Find a decorator by name.
|
<C> Helper<C> |
helper(java.lang.String name)
Find a helper by name.
|
java.util.Set<java.util.Map.Entry<java.lang.String,Helper<?>>> |
helpers()
List all the helpers from registry.
|
HelperRegistry |
registerDecorator(java.lang.String name,
Decorator decorator)
Register a decorator and make it accessible via
HelperRegistry.decorator(String) . |
<H> HelperRegistry |
registerHelper(java.lang.String name,
Helper<H> helper)
Register a helper in the helper registry.
|
<H> HelperRegistry |
registerHelperMissing(Helper<H> helper)
Register the special helper missing in the registry.
|
HelperRegistry |
registerHelpers(java.lang.Class<?> helperSource)
Register all the helper methods for the given helper source.
|
HelperRegistry |
registerHelpers(java.io.File input)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(java.lang.Object helperSource)
Register all the helper methods for the given helper source.
|
HelperRegistry |
registerHelpers(java.lang.String filename,
java.io.InputStream source)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(java.lang.String filename,
java.io.Reader source)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(java.lang.String filename,
java.lang.String source)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(java.net.URI location)
Register helpers from a JavaScript source.
|
DefaultHelperRegistry |
with(HandlebarsJs handlebarsJs)
Set the handlebars Js.
|
public <C> Helper<C> helper(java.lang.String name)
HelperRegistry
helper
in interface HelperRegistry
C
- The helper runtime type.name
- The helper's name. Required.public <H> HelperRegistry registerHelper(java.lang.String name, Helper<H> helper)
HelperRegistry
registerHelper
in interface HelperRegistry
H
- The helper runtime type.name
- The helper's name. Required.helper
- The helper object. Required.public <H> HelperRegistry registerHelperMissing(Helper<H> helper)
HelperRegistry
registerHelperMissing
in interface HelperRegistry
H
- The helper runtime type.helper
- The helper object. Required.public HelperRegistry registerHelpers(java.lang.Object helperSource)
HelperRegistry
Register all the helper methods for the given helper source.
A helper method looks like:
public static? CharSequence methodName(context?, parameter*, options?) { }Where:
registerHelpers
in interface HelperRegistry
helperSource
- The helper source. Required.public HelperRegistry registerHelpers(java.lang.Class<?> helperSource)
HelperRegistry
Register all the helper methods for the given helper source.
A helper method looks like:
public static? CharSequence methodName(context?, parameter*, options?) { }Where:
Enums are supported too
registerHelpers
in interface HelperRegistry
helperSource
- The helper source. Enums are supported. Required.public HelperRegistry registerHelpers(java.net.URI location) throws java.lang.Exception
HelperRegistry
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.
registerHelpers
in interface HelperRegistry
location
- A classpath location. Required.java.lang.Exception
- If the JavaScript helpers can't be registered.public HelperRegistry registerHelpers(java.io.File input) throws java.lang.Exception
HelperRegistry
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.
registerHelpers
in interface HelperRegistry
input
- A JavaScript file name. Required.java.lang.Exception
- If the JavaScript helpers can't be registered.public HelperRegistry registerHelpers(java.lang.String filename, java.io.Reader source) throws java.lang.Exception
HelperRegistry
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.
registerHelpers
in interface HelperRegistry
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 HelperRegistry registerHelpers(java.lang.String filename, java.io.InputStream source) throws java.lang.Exception
HelperRegistry
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.
registerHelpers
in interface HelperRegistry
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 HelperRegistry registerHelpers(java.lang.String filename, java.lang.String source) throws java.lang.Exception
HelperRegistry
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.
registerHelpers
in interface HelperRegistry
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 java.util.Set<java.util.Map.Entry<java.lang.String,Helper<?>>> helpers()
HelperRegistry
helpers
in interface HelperRegistry
public Decorator decorator(java.lang.String name)
HelperRegistry
decorator
in interface HelperRegistry
name
- A decorator's name.null
.public HelperRegistry registerDecorator(java.lang.String name, Decorator decorator)
HelperRegistry
HelperRegistry.decorator(String)
.registerDecorator
in interface HelperRegistry
name
- A decorator's name. Required.decorator
- A decorator. Required.public DefaultHelperRegistry with(HandlebarsJs handlebarsJs)
handlebarsJs
- The handlebars Js. Required.Copyright © 2010 - 2020 Adobe. All Rights Reserved