|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.jknack.handlebars.Options
public abstract class Options
Options available for Helper.apply(Object, Options).
| Field Summary | |
|---|---|
Context |
context
The current context. |
Template |
fn
The current template. |
Handlebars |
handlebars
The Handlebars object. |
Map<String,Object> |
hash
The hash options. |
Template |
inverse
The current inverse template. |
Object[] |
params
The parameters. |
| Constructor Summary | |
|---|---|
Options(Handlebars handlebars,
Context context,
Template fn,
Template inverse,
Object[] params,
Map<String,Object> hash)
Creates a new Handlebars Options. |
|
| Method Summary | ||
|---|---|---|
abstract CharSequence |
apply(Template template)
Apply the given template to the default context. |
|
abstract CharSequence |
apply(Template template,
Object context)
Apply the given template to the provided context. |
|
abstract
|
data(String name)
Read the attribute from the data storage. |
|
abstract void |
data(String name,
Object value)
Set an attribute in the data storage. |
|
abstract CharSequence |
fn()
Apply the fn template using the default context. |
|
abstract CharSequence |
fn(Object context)
Apply the fn template using the provided context. |
|
abstract
|
get(String name)
Look for a value in the context's stack. |
|
abstract
|
get(String name,
T defaultValue)
Look for a value in the context's stack. |
|
|
hash(String name)
Find a value inside the hash attributes. |
|
|
hash(String name,
Object defaultValue)
Find a value inside the hash attributes. |
|
abstract CharSequence |
inverse()
Apply the inverse template using the default context. |
|
abstract CharSequence |
inverse(Object context)
Apply the inverse template using the provided context. |
|
boolean |
isEmpty(Object value)
Returns false if its argument is false, null or empty list/array (a "falsy" value). |
|
|
param(int index)
Return a parameter at given index. |
|
|
param(int index,
T defaultValue)
Return a parameter at given index. |
|
abstract Template |
partial(String path)
Return a previously registered partial in the current execution context. |
|
abstract void |
partial(String path,
Template partial)
Store a partial in the current execution context. |
|
Set<Map.Entry<String,Object>> |
propertySet(Object context)
List all the properties and their values for the given object. |
|
abstract Context |
wrap(Object model)
Creates a Context from the given model. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final Handlebars handlebars
Handlebars object. Not null.
public final Context context
public final Template fn
public final Template inverse
public final Object[] params
public final Map<String,Object> hash
| Constructor Detail |
|---|
public Options(Handlebars handlebars,
Context context,
Template fn,
Template inverse,
Object[] params,
Map<String,Object> hash)
Options.
handlebars - The handlebars instance. Required.context - The current context. Required.fn - The template function. Required.inverse - The inverse template function. Required.params - The parameters. Required.hash - The optional hash. Required.| Method Detail |
|---|
public abstract CharSequence fn()
throws IOException
fn template using the default context.
IOException - If a resource cannot be loaded.
public abstract CharSequence fn(Object context)
throws IOException
fn template using the provided context.
context - The context to use.
IOException - If a resource cannot be loaded.
public abstract CharSequence inverse()
throws IOException
inverse template using the default context.
IOException - If a resource cannot be loaded.
public abstract CharSequence inverse(Object context)
throws IOException
inverse template using the provided context.
context - The context to use.
IOException - If a resource cannot be loaded.
public abstract CharSequence apply(Template template,
Object context)
throws IOException
template - The template.context - The context object.
IOException - If a resource cannot be loaded.
public abstract CharSequence apply(Template template)
throws IOException
template - The template.
IOException - If a resource cannot be loaded.public final <T> T param(int index)
Return a parameter at given index. This is analogous to:
Object param = options.params[index]
The only difference is the type safe feature:
MyType param = options.param(index)
T - The runtime type.index - The parameter position.
public final <T> T param(int index,
T defaultValue)
Return a parameter at given index. This is analogous to:
Object param = options.params[index]
The only difference is the type safe feature:
MyType param = options.param(index)
T - The runtime type.index - The parameter position.defaultValue - The default value to return if the parameter is not
present or if null.
public abstract <T> T get(String name,
T defaultValue)
T - The runtime type.name - The property's name.defaultValue - The default value to return if the attribute is not
present or if null.
null if it's not found.public abstract <T> T get(String name)
T - The runtime type.name - The property's name.
null if it's not found.public abstract Template partial(String path)
path - The partial's path. Required.
null if not found.
public abstract void partial(String path,
Template partial)
path - The partial's path. Required.partial - The partial template. Required.public final <T> T hash(String name)
Find a value inside the hash attributes. This is analogous to:
Object myClass = options.hash.get("class");
This mehtod works as a shorthand and type safe call:
String myClass = options.hash("class");
T - The runtime type.name - The hash's name.
public final <T> T hash(String name,
Object defaultValue)
Find a value inside the hash attributes. This is analogous to:
Object myClass = options.hash.get("class");
This method works as a shorthand and type safe call:
String myClass = options.hash("class");
T - The runtime type.name - The hash's name.defaultValue - The default value to returns.
public final boolean isEmpty(Object value)
value - A value.
public abstract Context wrap(Object model)
Context from the given model. If the object is a context
already the same object will be returned.
model - The model object.
public abstract <T> T data(String name)
T - Data type.name - The attribute's name.
public abstract void data(String name,
Object value)
name - The attribute's name. Required.value - The attribute's value. Required.public Set<Map.Entry<String,Object>> propertySet(Object context)
context - The context object. Not null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||