I am trying to write a {{< gallery >}} shortcode that will either generate a gallery with all the images in a directory you define, the contents you define via .Inner, or simply all the image resources related to the page. Here are the forms I’m trying to support:
{{< gallery >}} - use all the image resources for tht page
I can process the first two, but it is not clear to me how to determine if there nothing in the .Inner variable so I can process form 3 above. I would expect to do something like the following:
{{ with (.Get "dir") }}
// do stuff with the specified directory (works fine)
{{ else }}
{{ if .Inner }}
{{ .Inner }} // Always executes
{{ else }}
// do stuff related to resources in this page
{{ end }}
{{ end }}
How do I detect a bare shortcode with no arguments nor inner content?
I’m only specifying {{< gallery >}} on a line by itself. There are no open/close shortcodes.
---
front matter
---
This is my gallery.
{{< load-photoswipe >}}
{{< gallery >}}
The above is essentially my test page. There are about a dozen images in the same directory as the page. I’d like to display all the images in that posts directory.
{{ .Inner }} implies that you have at least {{< gallery >}}{{< /gallery >}}, I don’t think you can have shortcodes that close itself AND take .inner codings. So if you want to support {{< gallery >}}something{{< /gallery >}} you will have to have closing tags.