HideWhen Component ReferenceShowWhen Component Referencetml`
<HideWhen hasValue=stateVariable1>
...
</HideWhen>
`tml`
<HideWhen hasValue="stateVariable1,stateVariable2">
...
</HideWhen>
`
tml`
<HideWhen hasValue=${SV.find(/stateVariable\d+/)}>
...
</HideWhen>
`
The HideWhen component hides its children whenever any of the state variables specified by the hasValue attribute have truthy values.
Otherwise, the children are rendered.
HideWhen is often useful in conjunction with ShowWhen to show an error message area when there is an error and show other results when this is no error:
For example:
tml`
<HideWhen hasValue=myPage_errorMsg>
<div>Results: {{myPage_results}}</>
</HideWhen>
<ShowWhen hasValue=myPage_errorMsg>
<div>Error: {{myPage_errorMsg}}</>
</ShowWhen>
`
The HideWhen component ignores the standard attributes.
hasValue
The hasValue attribute can accept:
The hasValue attribute will accept the output of SV.find(). Any argument acceptable to SV.find() is acceptable as a value of the hasValue attribute.
The HideWhen component accepts all children.
The HideWhen component is remounted when the hasValue conditions change.
hasValue conditions are not met, the Component renders the children.hasValue conditions are met, the Component renders a single <span> with the class whenMarker. This allows the Component to keep a placeholder for any future template nodes.