com.github.jknack.handlebars.helper
Class EachHelper

java.lang.Object
  extended by com.github.jknack.handlebars.helper.EachHelper
All Implemented Interfaces:
Helper<Object>

public class EachHelper
extends Object
implements Helper<Object>

You can iterate over a list using the built-in each helper. Inside the block, you can use this to reference the element being iterated over.

Since:
0.3.0
Author:
edgar.espina

Field Summary
static Helper<Object> INSTANCE
          A singleton instance of this helper.
static String NAME
          The helper's name.
 
Constructor Summary
EachHelper()
           
 
Method Summary
 CharSequence apply(Object context, Options options)
          Callback method for execute the given method.
protected  Object next(Context parent, Iterator<Object> iterator, int index)
          Retrieve the next element available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final Helper<Object> INSTANCE
A singleton instance of this helper.


NAME

public static final String NAME
The helper's name.

See Also:
Constant Field Values
Constructor Detail

EachHelper

public EachHelper()
Method Detail

apply

public CharSequence apply(Object context,
                          Options options)
                   throws IOException
Description copied from interface: Helper
Callback method for execute the given method.

Specified by:
apply in interface Helper<Object>
Parameters:
context - The context object (param=0).
options - The options object.
Returns:
A string result.
Throws:
IOException - If a template cannot be loaded.

next

protected Object next(Context parent,
                      Iterator<Object> iterator,
                      int index)
Retrieve the next element available.

Parameters:
parent - The parent context.
iterator - The element iterator.
index - The nth position of this element. Zero base.
Returns:
The next element available.


Copyright © 2012. All Rights Reserved.