APIcast icon indicating copy to clipboard operation
APIcast copied to clipboard

Some liquid functions are not working - especially the time functions

Open pestanko opened this issue 5 years ago • 2 comments

All of the time functions are returning the empty string:

Functions: time, today, http_time, cookie_time, localtime, now, utctime

Version

3scale 2.3-CR1

Steps To Reproduce
  1. Create application
  2. add URL rewrite policy
  3. add rules for any of these functions with liquid Example: arg = {{ now }}
  4. Make a request and response should look like:
"args": "user_key=5941428bd561fa5a91489f2c36ed8cb3&arg=",
Current Result
{
  "method": "GET",
  "path": "/test/path",
  "args": "user_key=5941428bd561fa5a91489f2c36ed8cb3&arg=",
  "body": "",
...
}
Expected Result
{
  "method": "GET",
  "path": "/test/path",
  "args": "user_key=5941428bd561fa5a91489f2c36ed8cb3&arg=TIMESTAMP",
  "body": "",
...
}

pestanko avatar Sep 24 '18 12:09 pestanko

Here is the issue in JIRA: https://issues.jboss.org/browse/THREESCALE-1329

WORKAROUND

Currently, how these functions work - it is required to call it this way: {{ <some_param> | now}}

So, for example, this works: {{ uri | now }}

pestanko avatar Sep 24 '18 12:09 pestanko

Hi @pestanko ,

This happens because we expose all the functions that you mention (now, utctime) as "liquid filters". Liquid filters are called like this: {{ arg | filter }} : https://help.shopify.com/en/themes/liquid/filters

The problem is that we shouldn't have exposed functions that do not receive any params as filters, because then, in order to call them something like {{ '' | filter }} is needed. We should expose these kind of functions as parameters, not as filters.

davidor avatar Sep 25 '18 08:09 davidor