public interface HelperRegistry
| Modifier and Type | Field and Description |
|---|---|
static String |
HELPER_MISSING
The missing helper's name.
|
| Modifier and Type | Method and Description |
|---|---|
Decorator |
decorator(String name)
Find a decorator by name.
|
<C> Helper<C> |
helper(String name)
Find a helper by name.
|
Set<Map.Entry<String,Helper<?>>> |
helpers()
List all the helpers from registry.
|
HelperRegistry |
registerDecorator(String name,
Decorator decorator)
Register a decorator and make it accessible via
decorator(String). |
<H> HelperRegistry |
registerHelper(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(Class<?> helperSource)
Register all the helper methods for the given helper source.
|
HelperRegistry |
registerHelpers(File input)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(Object helperSource)
Register all the helper methods for the given helper source.
|
HelperRegistry |
registerHelpers(String filename,
InputStream source)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(String filename,
Reader source)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(String filename,
String source)
Register helpers from a JavaScript source.
|
HelperRegistry |
registerHelpers(URI location)
Register helpers from a JavaScript source.
|
HelperRegistry |
setCharset(Charset charset)
Set the charset to use.
|
static final String HELPER_MISSING
<C> Helper<C> helper(String name)
C - The helper runtime type.name - The helper's name. Required.Set<Map.Entry<String,Helper<?>>> helpers()
<H> HelperRegistry registerHelper(String name, Helper<H> helper)
H - The helper runtime type.name - The helper's name. Required.helper - The helper object. Required.<H> HelperRegistry registerHelperMissing(Helper<H> helper)
H - The helper runtime type.helper - The helper object. Required.HelperRegistry registerHelpers(Object helperSource)
Register all the helper methods for the given helper source.
A helper method looks like:
public static? CharSequence methodName(context?, parameter*, options?) {
}
Where:
helperSource - The helper source. Required.HelperRegistry registerHelpers(Class<?> helperSource)
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
helperSource - The helper source. Enums are supported. Required.HelperRegistry registerHelpers(URI location) throws 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.location - A classpath location. Required.Exception - If the JavaScript helpers can't be registered.HelperRegistry registerHelpers(File input) throws 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.input - A JavaScript file name. Required.Exception - If the JavaScript helpers can't be registered.HelperRegistry registerHelpers(String filename, Reader source) throws 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.Exception - If the JavaScript helpers can't be registered.HelperRegistry registerHelpers(String filename, InputStream source) throws 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.Exception - If the JavaScript helpers can't be registered.HelperRegistry registerHelpers(String filename, String source) throws IOException
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.IOException - If the JavaScript helpers can't be registered.Decorator decorator(String name)
name - A decorator's name.null.HelperRegistry registerDecorator(String name, Decorator decorator)
decorator(String).name - A decorator's name. Required.decorator - A decorator. Required.HelperRegistry setCharset(Charset charset)
charset - Charset.Copyright © 2018. All rights reserved.