Platform Update
September 20, 2018
Improvement
In this release notes we will focus on new liquid filters, fixed filter and one new feature.
This filter allows you to add new key-value pairs into existing hash.
`
{% assign accountants = "Angela,Kevin,Oscar" | split: "," %}
{% assign management = "David,Jan,Michael" | split: "," %}
{% assign company = '{}' | to_hash %}
{% assign company = company | assign_to_hash_key: "name", "Dunder Mifflin" %}
{% assign company = company | assign_to_hash_key: "accountants", accountants %}
{% assign company = company | assign_to_hash_key: "management", management %}
{{ company }}
`
Result:
`{"name"=>"Dunder Mifflin", "accountants"=>["Angela", "Kevin", "Oscar"], "management"=>["David", "Jan", "Michael"]}
`
This filter allows you to sanitize user input before rendering it and at the same time decide which attributes should not be sanitized.
`
{% capture link %}
Link
{% endcapture %}
{{ link | sanitize }} => Link
{% assign whitelist_attributes = 'target' | split: '|' %}
{{ link | sanitize: whitelist_attributes }}
`
Result:
`Link
`
There was a community request to make it easier to access useragent and parse it, so here it is.
You can access useragent string (as you normally could in the past)
This filter takes useragent string as an input and returns object with parsed data about it.
`
{{ context.headers.HTTP_USER_AGENT | useragent }}
`
You can use json filter for readability:
`
{{ context.headers.HTTP_USER_AGENT | useragent | json }}
`
This filter was returning string that was longer than expected. Now it returns string of length that you want.
`
{{ 10 | random_string }} => '6a1e7e2629'
{{ 2 | random_string }} => '8b'
`
You have the possibility to send binary files in API call. This might be useful when integrating your system with external APIs that require additional data from your users, for example photo.
Read guide [Sending a Binary File Using an API Call Notification] to learn more.
New Feature
Platform Update
September 03, 2018
Improvement
We are introducing two filters to allow you usage of [JSON Web Tokens].
Valid options for algorithm:
none - unsigned token
HS256 - HMAC using SHA-256
HS384 - HMAC using SHA-384
HS512 - HMAC using SHA-512
RS256 - RSA using SHA-256
RS384 - RSA using SHA-384
RS512 - RSA using SHA-512
Example:
`
{{ payload | jwt_encode: 'HS256', 'this-is-secret' }} => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJ2YWx1ZSIsImFub3RoZXJfa2V5IjoiYW5vdGhlciB2YWx1ZSJ9.XT8sHXyPTA9DoHzssXh1q6Uv2D1ENosW0F3Ixle85L0'
`
Valid options for algorithm:
none - unsigned token
HS256 - HMAC using SHA-256
HS384 - HMAC using SHA-384
HS512 - HMAC using SHA-512
RS256 - RSA using SHA-256
RS384 - RSA using SHA-384
RS512 - RSA using SHA-512
Examples:
`
{% assign original_payload = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJ2YWx1ZSIsImFub3RoZXJfa2V5IjoiYW5vdGhlciB2YWx1ZSJ9.XT8sHXyPTA9DoHzssXh1q6Uv2D1ENosW0F3Ixle85L0' | jwt_decode: 'HS256', 'this-is-secret' }} =>
[
{
"key" => "value",
"another_key" => "another value"
},
{
"typ" => "JWT",
"alg" => "HS256"
}
]
`
`
{% capture public_key %}
-----BEGIN PUBLIC KEY-----
MIIBI...
-----END PUBLIC KEY-----
{% endcapture %}
{% assign original_payload = 'some encoded token' | jwt_decode: 'RS256', public_key %}
`
Read more at our [Liquid filters documentation].
Errors shown by [pos-cli logs] are now more detailed. It should help you debug your application.
Example:
`
[2018-09-03 13:59:29.049Z] - Liquid::ArgumentError: jwt_encode filter - first argument must be a hash or a string, received:
page: pages/release-notes/2018-09-03
`
Platform Update
July 30, 2018
Improvement
New tag allows you to use normal liquid syntax to pass variables. render_form tag is now deprecated.
`
{% render_form edit_user, id: @user.id %}
`
now should be written with
`
{% include_form 'edit_user', id: user.id %}
`
Warning
You have to quote form name and you do not include "@" when passing variable.
Until now you had log mutation at your disposal, but it was a lot of work to use for such a simple task.
From now on please use log tag to print something to logs.
`
{% log "hello world" %}
{% log params %}
{% log params, type: 'error' %}
`
Note
Default type is info.
New Feature