|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.jknack.handlebars.Handlebars
public class Handlebars
Handlebars provides the power necessary to let you build semantic templates effectively with no frustration.
Usage:
Handlebars handlebars = new Handlebars();
Template template = handlebars.compile("Hello {{name}}!");
Person person = new Person("John", "Doe");
String output = template.apply(person);
assertEquals("Hello John!", output);
| Nested Class Summary | |
|---|---|
static class |
Handlebars.SafeString
A Handlebars.SafeString tell Handlebars that the content should not be
escaped as HTML. |
static class |
Handlebars.Utils
Utilities function like: Handlebars.Utils.escapeExpression(CharSequence) and
Handlebars.Utils.isEmpty(Object). |
| Field Summary | |
|---|---|
static String |
DELIM_END
The default end delimiter. |
static String |
DELIM_START
The default start delimiter. |
static String |
HELPER_MISSING
The missing helper's name. |
| Constructor Summary | |
|---|---|
Handlebars()
Creates a new Handlebars with a ClassTemplateLoader and no
cache. |
|
Handlebars(TemplateLoader loader)
Creates a new Handlebars with no cache. |
|
Handlebars(TemplateLoader loader,
TemplateCache cache)
Creates a new Handlebars. |
|
| Method Summary | ||
|---|---|---|
Template |
compile(String input)
Compile a handlebars template. |
|
Template |
compile(String input,
String startDelimiter,
String endDelimiter)
Compile a handlebars template. |
|
Template |
compile(URI uri)
Compile the resource located at the given uri. |
|
Template |
compile(URI uri,
String startDelimiter,
String endDelimiter)
Compile the resource located at the given uri. |
|
static void |
debug(String message)
Log the given message as debug and format the message within the args. |
|
static void |
debug(String message,
Object... args)
Log the given message as debug and format the message within the args. |
|
static void |
error(String message)
Log the given message as error and format the message within the args. |
|
static void |
error(String message,
Object... args)
Log the given message as error and format the message within the args. |
|
TemplateLoader |
getTemplateLoader()
The resource locator. |
|
|
helper(String name)
Find a helper by it's name. |
|
boolean |
isStringParams()
If true, missing helper parameters will be resolve to their names. |
|
static void |
log(String message)
Log the given message and format the message within the args. |
|
static void |
log(String message,
Object... args)
Log the given message and format the message within the args. |
|
|
registerHelper(String name,
Helper<H> helper)
Register a helper in the helper registry. |
|
void |
setStringParams(boolean stringParams)
If true, missing helper parameters will be resolve to their names. |
|
static void |
warn(String message)
Log the given message as warn and format the message within the args. |
|
static void |
warn(String message,
Object... args)
Log the given message as warn and format the message within the args. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String HELPER_MISSING
public static final String DELIM_START
public static final String DELIM_END
| Constructor Detail |
|---|
public Handlebars(TemplateLoader loader,
TemplateCache cache)
Handlebars.
loader - The template loader. Required.cache - The template cache. Required.public Handlebars(TemplateLoader loader)
Handlebars with no cache.
loader - The template loader. Required.public Handlebars()
Handlebars with a ClassTemplateLoader and no
cache.
| Method Detail |
|---|
public Template compile(URI uri)
throws IOException
uri - The resource's location. Required.
IOException - If the resource cannot be loaded.
public Template compile(URI uri,
String startDelimiter,
String endDelimiter)
throws IOException
uri - The resource's location. Required.startDelimiter - The start delimiter. Required.endDelimiter - The end delimiter. Required.
IOException - If the resource cannot be loaded.
public Template compile(String input)
throws IOException
input - The handlebars input. Required.
IOException - If the resource cannot be loaded.
public Template compile(String input,
String startDelimiter,
String endDelimiter)
throws IOException
input - The input text. Required.startDelimiter - The start delimiter. Required.endDelimiter - The end delimiter. Required.
IOException - If the resource cannot be loaded.public <C> Helper<C> helper(String name)
C - The helper runtime type.name - The helper's name. Required.
public <H> Handlebars registerHelper(String name,
Helper<H> helper)
H - The helper runtime type.name - The helper's name. Required.helper - The helper object. Required.
public TemplateLoader getTemplateLoader()
public boolean isStringParams()
public void setStringParams(boolean stringParams)
stringParams - If true, missing helper parameters will be resolve to
their names.
public static void log(String message,
Object... args)
message - The log's message.args - The optional args.String#format(String, Object...)public static void log(String message)
message - The log's message.String#format(String, Object...)
public static void warn(String message,
Object... args)
message - The log's message.args - The optional args.String#format(String, Object...)public static void warn(String message)
message - The log's message.String#format(String, Object...)
public static void debug(String message,
Object... args)
message - The log's message.args - The optional args.String#format(String, Object...)public static void debug(String message)
message - The log's message.String#format(String, Object...)
public static void error(String message,
Object... args)
message - The log's message.args - The optional args.String#format(String, Object...)public static void error(String message)
message - The log's message.String#format(String, Object...)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||