I found out the following way to solve the issue
__files/search-response-e.json
{{#assign 'page-size'}}20{{/assign~}}
{{#each request.query}}
{{#if (eq @key 'size')}}
{{#assign 'page-size}}
{{this}}
{{/assign~}}
{{/if~}}
{{/each~}}
Iterating over the request.query
content doesn't include the size
property when it's not sent as a query parameter. So it is possible to iterate over all elements in request.query
, check if any of the keys matches the parameter {{#if (eq @key 'size')}}
and then assign the value replacing the default one if the parameter is present.
It is a solution but it's also very verbose and weird to understand what it's doing at first glance. I would appreciate it if anyone knows a better and cleaner way to solve this.