Anko Pseudo-Script
Although Golang templates are very powerful and it should be the preferred way to go when you need to manipulate data, sometimes you need more advanced scripting capabilities.
Anko is a pseudo-go language that is able to manipulate all sorts of objects. It is better to be familiar with the Go language, although not necessary if you just need to write a simple script.
Basic Syntax¶
Syntax is a simplified version of Golang (we can highlight it with Javascript grammar, although it is not). Below is an example as provided by Anko Repository. Refer to this repository for mors examples.
Input / Output¶
To add scripting, simply add an "Anko" action to your Flow. As any other actions, it will receive an Input and is expected to return with an Output in the same ActionMessage
format. This is simply done by injecting the input
variable in the script, and expecting you to declare an output
variable. Generally, you will just have to clone the input:
Importing Libraries¶
Most Golang standard libraries are available for importing, using a lib = import("lib")
syntax. Cells Flows provides additional libraries that can be imported, as well a "Services" that are directly available in the scope of the script. See some examples below.
Hello World:
Standard Libs:
Logger Service (no need to import):
Cells-defined libraries and enriching Output:
Using Playground¶
As the syntax is not straight-forward and cannot be validated directly, the Playground (see next section) provides an Anko mode to at least validate the syntax before saving.