If ne (.Scratch.Get "field") - not work(

Hello. I upgraded to 0.92.2 version and now I have problems with
{{ if ne (.Scratch.Get "field") }}
how can I replace this condition?

(.Scratch.Get "field") returns a value. Want do you want to compare it to?

I need a condition - if the variable is not declared.

{{ if .Scratch.Get "field" }}
  It is defined
{{ else }}
  It is not defined
{{ end }}

Maybe there is an option to write like this - {{ if not isset .Scratch.Get "field" }} ?

{{ if not (.Scratch.Get "field") }}
  It is not defined
{{ end }}

To be more precise

{{ if not (.Scratch.Get "field") }}
  It is not truthy
{{ end }}

On a side note: I too have cases recently where if ne stopped working (aka did not return the same as before) around 0.92. Did anything important change? I could try to find some cases to go deeper on this.

Yes. We fixed a problem.
https://github.com/gohugoio/hugo/issues/9462

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.