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_TYPES
HELPER_TAG_TYPES
configuration
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.
|
allowedTagTypes
getRequiredHashKeys
append, convertAndAppend, convertValue, init, isSection, isUnescapeVariable, isVariable
checkNotInitialized, init
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfigurationKeys, init
public void execute(Options options)
Helper
public void validate(HelperDefinition definition)
Helper
MustacheException
with code
MustacheProblem.COMPILE_HELPER_VALIDATION_FAILURE
should be
thrown in case of validation failure occurs.validate
in interface Helper
validate
in class BasicHelper
protected int numberOfRequiredParameters()
numberOfRequiredParameters
in class BasicHelper
protected int numberOfRequiredHashEntries()
numberOfRequiredHashEntries
in class BasicHelper
protected Set<String> getSupportedHashKeys()
getSupportedHashKeys
in class BasicHelper
*
to
allow any hash keysCopyright © 2017. All rights reserved.