|
|
This is the Documentation for Snow 0.4, old 0.3 docs can be found [here](https://github.com/bipio-server/bipio/wiki/Transforms-And-Templates-(Sansa-0.3)).
|
|
|
|
|
|
Transforms are used by Bip `hub` objects to map and combine attributes between adjacent channels. They are a JSON object where the object keys are the named imports of a target channel on a hub and the value is the data to inject, evaluated as a text template.
|
|
|
|
|
|
For example if we have an [email.smtp_forward channel](https://bip.io/docs/pods/email) and we want to set two of its imports, `subject` and `body_text`. We can inject custom values like so :
|
... | ... | @@ -9,16 +11,16 @@ For example if we have an [email.smtp_forward channel](https://bip.io/docs/pods/ |
|
|
}
|
|
|
```
|
|
|
|
|
|
Templates can also be interpolated with variables from upstream channels or metadata if they take the form
|
|
|
Templates can also be interpolated with variables from upstream channels or metadata as [JSON Paths](http://goessner.net/articles/JsonPath/) if they take the form
|
|
|
|
|
|
`[%(source|_client|_bip|channel id)#json_path%]`
|
|
|
`[%source.title%]`
|
|
|
|
|
|
`json_path` in the example means the [JSON Path](http://goessner.net/articles/JsonPath/) of an attribute exported by an upstream channel, keyed by either an explicit channel id, or `source` (ie: whatever the bip receives or generates). This means you can concatenate exports and text together to create a custom import. With the previous email example, lets assume we're using an `smtp` bip and want to pass through some of the details to an email channel on its hub :
|
|
|
|
|
|
```
|
|
|
{
|
|
|
"subject" : "[%source#subject%]",
|
|
|
"body_text" : "I got an email from [%_client#repr%] : [%source#body_text%]"
|
|
|
"subject" : "[%source.subject%]",
|
|
|
"body_text" : "I got an email from [%_client.repr%] : [%source.body_text%]"
|
|
|
}
|
|
|
```
|
|
|
|
... | ... | @@ -49,7 +51,7 @@ It can transformed as : |
|
|
|
|
|
```
|
|
|
{
|
|
|
"json_document" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d#payload[1].body%]"
|
|
|
"json_document" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d.payload[1].body%]"
|
|
|
}
|
|
|
```
|
|
|
|
... | ... | @@ -57,8 +59,8 @@ Or to take the previous email forwarder example, we can just keep on drilling in |
|
|
|
|
|
```
|
|
|
{
|
|
|
"subject" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d#payload[1].body.title%]",
|
|
|
"body_text" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d#payload[1].body.message%]"
|
|
|
"subject" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d.payload[1].body.title%]",
|
|
|
"body_text" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d.payload[1].body.message%]"
|
|
|
}
|
|
|
```
|
|
|
|
... | ... | |