mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-23 14:39:32 +08:00
44 lines
1.6 KiB
YAML
44 lines
1.6 KiB
YAML
# Copyright 2020-2021 Lowdefy, Inc
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
_ref:
|
|
path: templates/operators.yaml.njk
|
|
transformer: templates/operatorsMethodTransformer.js
|
|
vars:
|
|
pageId: _if
|
|
pageTitle: _if
|
|
types: |
|
|
```
|
|
(arguments: {test: boolean, then: any, else: any}): any
|
|
```
|
|
description: |
|
|
The `_if` operator returns the `then` argument if it's `test` argument is `true`, and it's `else` argument if it is `false`. Generally other operators are used to evaluate the `test` argument.
|
|
arguments: |
|
|
###### object
|
|
- `test: boolean`: The boolean result of a test.
|
|
- `then: any`: The value to return if the test is `true`.
|
|
- `else: any`: The value to return if the test is `false`.
|
|
examples: |
|
|
###### Return a value based on a user input:
|
|
```yaml
|
|
_if:
|
|
test:
|
|
_eq:
|
|
- _state: text_input
|
|
- The password
|
|
then: The user entered the password
|
|
else: Access denied
|
|
```
|
|
Returns: `"The user entered the password"` if the text input's value is `"The password"`, else `"Access denied"`
|