I am trying to let my shortcode either have inner content or not and I am not sure if this is a “lazy programming” situation or just impossible:
I would assume, that with a line like the following Hugo would ignore it, if there is no closing tag:
{{ with .Inner }}
<em>{{ . }}</em>
{{ end }}
Sample 1:
{{< shortcode >}}Something inside{{< /shortcode >}}
Expected: italic “Something inside”
Hugo: italic “Something inside”
Sample 2:
{{< shortcode >}}
Expected: nothing, there is no inner content
Hugo: italic EVERYTHING after the shortcode.
Is there a way to have one single shortcode serve both, calls with and without inner content? Or maybe, to start with, is there a way to determine if .Inner
is existing or empty (which is two different states, one with a closing tag and one without)?
If Hugo is unable to have both versions in one shortcode layout I think that might be worth something exploring to be implemented?