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?
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 Please show the markdown call to your shortcode and the full shortcode.
https://gohugo.io/functions/chomp/
{{ if eq (strings.Chomp .Inner) "" }}
{{ warnf "Inner is empty" }}
{{ else }}
{{ warnf "Inner is not empty" }}
{{ end }}
2 Likes
Thanks, that solved my problem
1 Like
system
Closed
March 2, 2022, 5:50pm
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.