public class EachHelper extends BasicSectionHelper
{{#each items}}
{{name}}
{{/each}}
It's possible to apply a function to each element. The function must be an
instance of Function. Note that the function cannot be type-safe. If
the result does not equal to SKIP_RESULT it's used instead
of the original element. If the result equals to
SKIP_RESULT the element is skipped. This might be useful
to filter out unnecessary elements or to wrap/transform elements.
{{#each items apply=myFunction}}
{{name}}
{{/each}}
It's also possible to supply an alias to access the value of the current iteration:
{{#each items as='item'}}
{{item.name}}
{{/each}}
This helper could be used to iterate over multiple objects:
{{! First iterate over list1 and then iterate over list2}}
{{#each list1 list2}}
{{name}}
{{/each}}
Function| Modifier and Type | Field and Description |
|---|---|
static String |
SKIP_RESULT |
SECTION_TYPESHELPER_TAG_TYPESconfiguration| Constructor and Description |
|---|
EachHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Options options)
Execute the helper.
|
protected Set<String> |
getSupportedHashKeys() |
void |
init()
Can be overridden so that there's no need to call
super.init(Configuration). |
allowedTagTypesgetRequiredHashKeys, numberOfRequiredHashEntries, numberOfRequiredParameters, validateappend, convertAndAppend, convertValue, isSection, isUnescapeVariable, isVariablecheckNotInitialized, initclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConfigurationKeys, initpublic static final String SKIP_RESULT
public void init()
AbstractConfigurationAwaresuper.init(Configuration).init in class AbstractHelperpublic void execute(Options options)
Helperprotected Set<String> getSupportedHashKeys()
getSupportedHashKeys in class BasicHelper* to
allow any hash keysCopyright © 2017. All rights reserved.