mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-23 14:39:32 +08:00
75 lines
2.7 KiB
YAML
75 lines
2.7 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: _args
|
|
pageTitle: _args
|
|
types: |
|
|
```
|
|
(key: string): any
|
|
(all: boolean): any
|
|
(arguments: {
|
|
all?: boolean,
|
|
key?: string,
|
|
default?: any
|
|
}): any
|
|
```
|
|
description: |
|
|
The `_args` operator gets a value from the `arguments` array passed to a function operator. The `arguments` array is an array of all the positional arguments passed to the function.
|
|
arguments: |
|
|
###### string
|
|
If the `_args` operator is called with a string argument, the value of the key in the `arguments` array is returned. If the value is not found, `null` is returned. Dot notation and [block list indexes](/lists) are supported.
|
|
|
|
###### boolean
|
|
If the `_args` operator is called with boolean argument `true`, the entire `arguments` array is returned.
|
|
|
|
###### object
|
|
- `all: boolean`: If `all` is set to `true`, the entire `arguments` array is returned. One of `all` or `key` are required.
|
|
- `key: string`: The value of the key in the `arguments` array is returned. If the value is not found, `null`, or the specified default value is returned. Dot notation and [block list indexes](/lists) are supported. One of `all` or `key` are required.
|
|
- `default: any`: A value to return if the `key` is not found in `arguments`. By default, `null` is returned if a value is not found.
|
|
examples: |
|
|
###### Map over an array:
|
|
|
|
```yaml
|
|
_array.map:
|
|
on:
|
|
- firstName: Ted
|
|
lastName: Mosby
|
|
- firstName: Robin
|
|
lastName: Scherbatsky
|
|
- firstName: Marshall
|
|
lastName: Eriksen
|
|
- firstName: Lily
|
|
lastName: Aldrin
|
|
- firstName: Barney
|
|
lastName: Stinson
|
|
callback:
|
|
_function:
|
|
__string.concat:
|
|
- __args: 0.firstName
|
|
- ' '
|
|
- __args: 0.lastName
|
|
```
|
|
Returns:
|
|
```yaml
|
|
- Ted Mosby
|
|
- Robin Scherbatsky
|
|
- Marshall Eriksen
|
|
- Lily Aldrin
|
|
- Barney Stinson
|
|
```
|