If/else empty .Inner does not seem to work

Hello there,

I was trying to make a shortcode which depends on whether an .Inner variable has been given or not. I coded

{{ if eq .Inner "" }}
  Inner is empty
{{ else }}
{{ .Inner }}
{{ end }}

but that doesn’t seem to work. I also tried

    {{ with .Inner}}
      {{ . | markdownify}}
    {{ else }}
      "No Inner has been given"
    {{ end }}

with no succes. Could someone help? :slight_smile:

Why does the with method not work? I would expect a different problem than an EMPTY .Inner. By the way, an unset .Inner is NIL, not empty :wink: Please show the markdown call to your shortcode and the full shortcode.


{{ if eq (strings.Chomp .Inner) "" }}
  {{ warnf "Inner is empty" }}
{{ else }}
  {{ warnf "Inner is not empty" }}
{{ end }}

Thanks, that solved my problem :slight_smile:

1 Like

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