public class RepeatHelper extends BasicSectionHelper
{{#repeat times=3}}
Hello three times!
{{/repeat}}
Or until the while expression evaluates to a "falsy" value:
{{#with items.iterator}}
{{#repeat while=hasNext}}
{{next}}
{{/repeat}}
{{/with}}
An interesting use case might be using ListIterator to iterate over the list in reverse order:
{{#invoke items.size on=items m="listIterator"}}
{{#repeat while=hasPrevious}}
{{previous}}
{{/repeat}}
{{/invoke}}
Checker.isFalsy(Object)SECTION_TYPESHELPER_TAG_TYPESconfiguration| Constructor and Description |
|---|
RepeatHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Options options)
Execute the helper.
|
protected Set<String> |
getSupportedHashKeys() |
protected int |
numberOfRequiredHashEntries() |
protected int |
numberOfRequiredParameters() |
void |
validate(HelperDefinition definition)
Helper should validate the tag definition (e.g. number of parameters)
during compilation and fail fast if necessary.
|
allowedTagTypesgetRequiredHashKeysappend, convertAndAppend, convertValue, init, isSection, isUnescapeVariable, isVariablecheckNotInitialized, initclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConfigurationKeys, initpublic void execute(Options options)
Helperpublic void validate(HelperDefinition definition)
HelperMustacheException with code
MustacheProblem.COMPILE_HELPER_VALIDATION_FAILURE should be
thrown in case of validation failure occurs.validate in interface Helpervalidate in class BasicHelperprotected int numberOfRequiredParameters()
numberOfRequiredParameters in class BasicHelperprotected int numberOfRequiredHashEntries()
numberOfRequiredHashEntries in class BasicHelperprotected Set<String> getSupportedHashKeys()
getSupportedHashKeys in class BasicHelper* to
allow any hash keysCopyright © 2017. All rights reserved.