How to emulate IsNonEmpty function?

I have the rendering block below, but sometimes I need only the author or only the cite attribute, but currently the whole element is dependent on “author”. I would like the presence of a tag to dependent on either author or cite to be set… or be non-empty, as I don’t really know the difference.
Isset seems to do what I want, the problem is I don’t know how to tell “isset this (inclusive) OR that” and no combination has worked so far. “Isset this that” does work but it’s a AND function.

{{ $author :=  }}
{{ $cite   := .Attributes.cite    }}
  <blockquote {{ with $cite }} cite="{{.| safeHTML }}" {{end}}>
{{ .Inner | markdownify }}
  {{ with $author}}<figcaption><cite><strong>
{{.| markdownify }}
</strong>{{with $cite }} in {{$cite|markdownify}}{{end}}</cite>
</figcaption>{{ end }}</blockquote>

Thanks :smiling_face_with_three_hearts:

I think this should work:

{{ if and $author $cite }}
{{ end }}

not “if”, or
Naively I thought conditionals only dealt with binary variables… Silly me. So I didn’t try that.
Thanks !

1 Like

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