public class IfHelper extends BasicSectionHelper
{{#if item.active}} {{item.name}} {{/if}}
Multiple params may be evaluated. The default evaluation logic is conjunction:
{{#if item.active item.valid}} Active and valid. {{/if}}
The evaluation logic may be specified:
{{#if item.active item.valid logic="or"}} Active or valid. {{/if}}
An optional else
may be specified. If not a string literal
Object.toString()
is used. The final string may contain simple value
expressions (evaluated in the same way as helper params). The default
delimiters are {
and }
. Note that for string
literals it's not possible to use the current template delimiters, i.e.
{{
and }}
.
{{#if item.active else="{item.name} is not active!"}} {{item.name}} is active! {{/if}}
Modifier and Type | Class and Description |
---|---|
protected static class |
MatchingSectionHelper.EvaluationLogic |
SECTION_TYPES
HELPER_TAG_TYPES
configuration
Constructor and Description |
---|
IfHelper() |
IfHelper(String elseStartDelimiter,
String elseEndDelimiter) |
Modifier and Type | Method and Description |
---|---|
void |
execute(Options options)
Execute the helper.
|
protected MatchingSectionHelper.EvaluationLogic |
getDefaultLogic() |
protected Set<String> |
getSupportedHashKeys() |
protected boolean |
hasEmptyParamsSupport() |
protected boolean |
isMatching(Object value) |
protected boolean |
isMatching(Object value,
Options options) |
protected int |
numberOfRequiredParameters() |
allowedTagTypes
getRequiredHashKeys, numberOfRequiredHashEntries, validate
append, convertAndAppend, convertValue, init, isSection, isUnescapeVariable, isVariable
checkNotInitialized, init
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfigurationKeys, init
protected boolean isMatching(Object value)
public void execute(Options options)
Helper
protected Set<String> getSupportedHashKeys()
getSupportedHashKeys
in class BasicHelper
*
to
allow any hash keysprotected MatchingSectionHelper.EvaluationLogic getDefaultLogic()
protected boolean hasEmptyParamsSupport()
protected int numberOfRequiredParameters()
numberOfRequiredParameters
in class BasicHelper
Copyright © 2017. All rights reserved.