public class SwitchHelper extends BasicSectionHelper
At the moment it's not possible to validate the helper content properly. It should only contain case and default sections. Other types of segments are always rendered. Note that the default section always terminates the flow!
Since we push the flow object on the context stack, it's possible to refer
the value in the switch expression with Nested.up() method. See also examples.
{{#switch "hello"}}
{{#case "foo" break="true"}}
Hello foo!
{{/case}}
{{#case "hello" break="true"}}
Hello world!
{{/case}}
{{#default}}
No case for {{this.up}}.
{{/default}}
{{/switch}}
By default, the following template will render "Hello world! No case for hello.":
{{#switch "hello"}}
{{#case "foo"}}
Hello foo!
{{/case}}
{{#case "hello"}}
Hello world!
{{/case}}
{{#default}}
No case for {{this.up}}.
{{/default}}
{{/switch}}
HelpersBuilder.addSwitch()| Modifier and Type | Class and Description |
|---|---|
static class |
SwitchHelper.CaseHelper
The first param is the matching value.
|
static class |
SwitchHelper.DefaultHelper |
SECTION_TYPESHELPER_TAG_TYPES| Constructor and Description |
|---|
SwitchHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Options options)
Execute the helper.
|
protected int |
numberOfRequiredParameters() |
allowedTagTypesnumberOfRequiredHashEntries, validateappend, getHashValue, init, isSection, isUnescapeVariable, isVariablegetConfigurationKeys, checkNotInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConfigurationKeysprotected int numberOfRequiredParameters()
numberOfRequiredParameters in class BasicHelperCopyright © 2014. All Rights Reserved.