79789942

Date: 2025-10-14 08:01:13
Score: 3
Natty:
Report link

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.

Reasons:
  • Blacklisted phrase (1): anyone knows
  • Blacklisted phrase (1.5): would appreciate
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Kodex