rogain-component-if
Passes its children through if data
passes defined attribute tests. Any trees defined after the <Else />
will be passed through if data
doesn't pass attributes tests.
The attributes and
, or
, and not
can be used to define how all tests should logically be grouped. The attribute predicates equal
, defined
, empty
, gt
, gte
, lt
, lte
can be used to test against the data
attribute value.
Attributes
Attribute | Description |
---|---|
data | Variable or Expression. |
and | Runs all tests with AND logic, short circuits when any predicate fails. The default is and if or is not defined. |
or | Runs all predicates with OR logic, short cicuits when any predicate passes. |
not | Negates the end result of all tests. |
Attribute Predicates
Attribute | Description |
---|---|
equal | Variable or Expression. returns true if it's value is equal to data |
defined | if defined, returns true if data is defined |
empty | if defined, returns true if data is an empty array or object |
gt | Variable or Expression. returns true if it's value is greater than data |
gte | Variable or Expression. returns true if it's value is greater than or equal to data |
lt | Variable or Expression. returns true if it's value is less than data |
lte | Variable or Expression. returns true if it's value is thess than or equal to data |
Examples
Default Predicates / Else
If no tests are defined, the default predicates are <If data={var} and defined empty="false"></If>
Negated Predicates
Way to go, no errors!Way to go, no errors!
Complex Predicates
If and
or or
attributes aren't defined the predicates will be run using AND logic by default.
10 - 99100 - 9991000+
OR Logic
MY THINGS BE MISSING
Install
With npm do:
npm install rogain-component-if
License
MIT