我正在尝试编写一个{{< gallery >}}
短代码,它将生成一个画廊,其中包含您定义的目录中的所有图像、您通过定义的内容.Inner
,或者只是与页面相关的所有图像资源。以下是我试图支持的表格:
{{< gallery dir="/gallery/alaska/" />}}
- 指定目录{{< gallery >}} {{< figure src="image1.jpg" >}} {{< /gallery >}}
- 指定的内部内容{{< gallery >}}
- 使用所有图像资源
我可以处理前两个,但我不清楚如何确定.Inner
变量中是否没有任何内容,因此我可以处理上面的表格 3。我希望执行以下操作:
{{- 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 }}
如何检测没有参数或内部内容的裸简码?