hasura / kriti-lang

A minimal JSON templating language
Apache License 2.0
56 stars 9 forks source link

How to return nothing in else condition? #52

Open christophediprima opened 2 years ago

christophediprima commented 2 years ago

I am trying to generate an Elastic search payload using Hasura Rest transformers.

Is there a way to return nothing in the {{else}} condition? I tried using {{end}} directly as I don't need an {{else}} but the parser fails. I also tried to use void but it also fails to parse.

Here is what I am trying to do:

{
    "query": {
    "bool": {
        "must": [
              {{if $body?.input?.search != null }}
              {
            "match": {
                "content.text": "{{$body?.input?.search}}"
                }
               }
              {{else}}
                           void
                      {{end}}
        ]
    }
    }
}
solomon-b commented 2 years ago

Hi. Sorry for the slow response time!

We have some standard library functions in the Kriti repo which would resolve this issue for you, but they aren't made available in HGE. I'm looking into how we can correct this now.

christophediprima commented 1 year ago

Hi! Is there a solution to the issue now? :)