HUGO checking for the existence of a variable in a shortcode

136 views Asked by At

I need to check the variable "text" in a shortcode, if it exists then {{ .Inner | markdownify}}

It is important that the variable simply exists and has no value and the shock code does not need to be closed if there is "text" {{<toc text>}}

I tried this solution but it gives an ERROR: failed to extract shortcode: shortcode "toc" must be closed or self-closed

{{ if isset .Params `text` }}
    <div class="col">
        {{ .Inner | markdownify }}
    </div>
{{ end }}
1

There are 1 answers

0
Mr. Hugo On

I think it should be:

{{ if isset .Params.text }}
    <div class="col">
        {{ .Inner | markdownify }}
    </div>
{{ end }}