Package com.github.jknack.handlebars
Class Options
java.lang.Object
com.github.jknack.handlebars.Options
Deprecated.
com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.
Options available for
Helper.apply(Object, Options).
Usage:
Options options = new Options.Builder(handlebars, context, fn)
.build();
Optionally you can set parameters and hash table:
Options options = new Options.Builder(handlebars, context, fn)
.setParams(new Object[] {})
.setHash(hash)
.build();
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDeprecated.com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.static classDeprecated.com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.static classDeprecated.com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.static classDeprecated.com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM. -
Field Summary
FieldsModifier and TypeFieldDescriptionDeprecated.Block param names.final ContextDeprecated.The current context.final TemplateDeprecated.The current template.final HandlebarsDeprecated.TheHandlebarsobject.Deprecated.The hash options.final StringDeprecated.The name of the helper.final TemplateDeprecated.The current inverse template.final Object[]Deprecated.The parameters.final TagTypeDeprecated.TheTagTypefrom where the helper was called. -
Constructor Summary
ConstructorsConstructorDescriptionOptions(Handlebars handlebars, String helperName, TagType tagType, Context context, Template fn, Template inverse, Object[] params, Map<String, Object> hash, List<String> blockParams) Deprecated.Creates a new HandlebarsOptions.Options(Handlebars handlebars, String helperName, TagType tagType, Context context, Template fn, Template inverse, Object[] params, Map<String, Object> hash, List<String> blockParams, Writer writer) Deprecated.Creates a new HandlebarsOptions. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Apply the given template to the default context.Deprecated.Apply the given template to the provided context.Deprecated.Apply the given template to the provided context.Deprecated.Apply the given template to the provided context.Deprecated.Apply the given template to the provided context.buffer()Deprecated.Get a Buffer which probably increase rendering time (performance).<T> TDeprecated.Read the attribute from the data storage.voidDeprecated.Set an attribute in the data storage.fn()Deprecated.Apply thefntemplate using the default context.Deprecated.Apply thefntemplate using the provided context.Deprecated.Apply thefntemplate using the provided context.<T> TDeprecated.Look for a value in the context's stack.<T> TDeprecated.Look for a value in the context's stack.<T> TDeprecated.Find a value inside thehashattributes.<T> TDeprecated.Find a value inside thehashattributes.inverse()Deprecated.Apply theinversetemplate using the default context.Deprecated.Apply theinversetemplate using the provided context.Deprecated.Apply theinversetemplate using the provided context.booleanDeprecated.Returns false if its argument is false, null or empty list/array (a "falsy" value).<T> Tparam(int index) Deprecated.Return a parameter at given index.<T> Tparam(int index, T defaultValue) Deprecated.Return a parameter at given index.Deprecated.Return a previously registered partial in the current execution context.voidDeprecated.Store a partial in the current execution context.propertySet(Object context) Deprecated.List all the properties and their values for the given object.Deprecated.Creates aContextfrom the given model.
-
Field Details
-
handlebars
Deprecated.TheHandlebarsobject. Not null. -
context
Deprecated.The current context. Not null. -
fn
Deprecated.The current template. Not null. -
inverse
Deprecated.The current inverse template. Not null. -
params
Deprecated.The parameters. Not null. -
hash
Deprecated.The hash options. Not null. -
tagType
Deprecated.TheTagTypefrom where the helper was called. -
helperName
Deprecated.The name of the helper. -
blockParams
Deprecated.Block param names.
-
-
Constructor Details
-
Options
public Options(Handlebars handlebars, String helperName, TagType tagType, Context context, Template fn, Template inverse, Object[] params, Map<String, Object> hash, List<String> blockParams) Deprecated.Creates a new HandlebarsOptions.- Parameters:
handlebars- The handlebars instance. Required.helperName- The name of the helper. Required.tagType- TheTagTypefrom where the helper was called.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.blockParams- The block param names. Required.
-
Options
public Options(Handlebars handlebars, String helperName, TagType tagType, Context context, Template fn, Template inverse, Object[] params, Map<String, Object> hash, List<String> blockParams, Writer writer) Deprecated.Creates a new HandlebarsOptions.- Parameters:
handlebars- The handlebars instance. Required.helperName- The name of the helper. Required.tagType- TheTagTypefrom where the helper was called.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.blockParams- The block param names. Required.writer- A writer. Optional.
-
-
Method Details
-
fn
Deprecated.Apply thefntemplate using the default context.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
fn
Deprecated.Apply thefntemplate using the provided context.- Parameters:
context- The context to use.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
fn
Deprecated.Apply thefntemplate using the provided context.- Parameters:
context- The context to use.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
inverse
Deprecated.Apply theinversetemplate using the default context.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
inverse
Deprecated.Apply theinversetemplate using the provided context.- Parameters:
context- The context to use.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
inverse
Deprecated.Apply theinversetemplate using the provided context.- Parameters:
context- The context to use.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
apply
Deprecated.Apply the given template to the provided context. The context stack is propagated allowing the access to the whole stack.- Parameters:
template- The template.context- The context object.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
apply
Deprecated.Apply the given template to the provided context. The context stack is propagated allowing the access to the whole stack.- Parameters:
template- The template.context- The context object.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
apply
public CharSequence apply(Template template, Context context, List<Object> blockParams) throws IOException Deprecated.Apply the given template to the provided context. The context stack is propagated allowing the access to the whole stack.- Parameters:
template- The template.context- The context object.blockParams- The block param values.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
apply
public CharSequence apply(Template template, Object context, List<Object> blockParams) throws IOException Deprecated.Apply the given template to the provided context. The context stack is propagated allowing the access to the whole stack.- Parameters:
template- The template.context- The context object.blockParams- The block param values.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
apply
Deprecated.Apply the given template to the default context. The context stack is propagated allowing the access to the whole stack.- Parameters:
template- The template.- Returns:
- The resulting text.
- Throws:
IOException- If a resource cannot be loaded.
-
param
public <T> T param(int index) Deprecated.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)- Type Parameters:
T- The runtime type.- Parameters:
index- The parameter position.- Returns:
- The parameter's value.
-
param
public <T> T param(int index, T defaultValue) Deprecated.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)- Type Parameters:
T- The runtime type.- Parameters:
index- The parameter position.defaultValue- The default value to return if the parameter is not present or if null.- Returns:
- The parameter's value.
-
get
Deprecated.Look for a value in the context's stack.- Type Parameters:
T- The runtime type.- Parameters:
name- The property's name.defaultValue- The default value to return if the attribute is not present or if null.- Returns:
- The associated value or
nullif it's not found.
-
get
Deprecated.Look for a value in the context's stack.- Type Parameters:
T- The runtime type.- Parameters:
name- The property's name.- Returns:
- The associated value or
nullif it's not found.
-
partial
Deprecated.Return a previously registered partial in the current execution context.- Parameters:
path- The partial's path. Required.- Returns:
- A previously registered partial in the current execution context.
Or
nullif not found.
-
partial
Deprecated.Store a partial in the current execution context.- Parameters:
path- The partial's path. Required.partial- The partial template. Required.
-
hash
Deprecated.Find a value inside the
hashattributes. 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");- Type Parameters:
T- The runtime type.- Parameters:
name- The hash's name.- Returns:
- The hash value or null.
-
hash
Deprecated.Find a value inside the
hashattributes. 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");- Type Parameters:
T- The runtime type.- Parameters:
name- The hash's name.defaultValue- The default value to returns.- Returns:
- The hash value or null.
-
isFalsy
Deprecated.Returns false if its argument is false, null or empty list/array (a "falsy" value).- Parameters:
value- A value.- Returns:
- False if its argument is false, null or empty list/array (a "falsy" value).
-
wrap
Deprecated.Creates aContextfrom the given model. If the object is a context already the same object will be returned.- Parameters:
model- The model object.- Returns:
- A context representing the model or the same model if it's a context already.
-
data
Deprecated.Read the attribute from the data storage.- Type Parameters:
T- Data type.- Parameters:
name- The attribute's name.- Returns:
- The attribute value or null.
-
data
Deprecated.Set an attribute in the data storage.- Parameters:
name- The attribute's name. Required.value- The attribute's value. Required.
-
propertySet
Deprecated.List all the properties and their values for the given object.- Parameters:
context- The context object. Not null.- Returns:
- All the properties and their values for the given object.
-
buffer
Deprecated.Get a Buffer which probably increase rendering time (performance). Usage:public CharSequence helper(Object ctx, Options options) { Buffer buffer = options.buffer(); ... buffer.append(...); ... return buffer; }Something to keep in mind is that when using the native buffer there won't be any visible output. For exampleOptions.NativeBuffer.toString()results in an empty string, that's expected because the content is written directly to the underlying writer.- Returns:
- A new buffer.
-