Shortcode not rendering parm inside of css class

Hi I am working on a custom shortcode that I want to use to create an accordion/dropdown block. The shortcode works except for one parm that is not being rendered. I followed the instructions from the Create Your Own Shortcodes Documentation. Please note that I am using hugo 0.40.3.
the parm that is not rendering is:

<div id="collapse1" class="panel-collapse collapse {.Get `col`}">

Which tells the accordion to start collapsed.

Here is the shortcode tag itself:

{{% accordion title="test" col="in" %}}
this is a test description
{{% /accordion %}}

Here is the shortcode file:

<div class="panel-group" id="accordion">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h2 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">{{ .Get "title" }}</a>
      </h2>
    </div>
    {{- if .Get "col"}}
    <div id="collapse1" class="panel-collapse collapse {.Get `col`}">
      <div class="panel-body"><p>{{ .Inner | markdownify }}</p></div>
    </div>
    {{- else}}
    <div id="collapse1" class="panel-collapse collapse">
      <div class="panel-body"><p>{{ .Inner | markdownify }}</p></div>
    </div>
    {{- end -}}
  </div>
</div>

Eyeballing it: are you using backticks instead of quotes?

and come to the latest version 0.70 :wink:

Quotes will not work in side of css attributes:

Building sites … ERROR 2020/05/08 13:51:17 error processing shortcode "shortcodes/accordion.html" for page "home\\about.md": html/template:shortcodes/accordion.html: "\"" in attribute name: "col\"}\">\r\n      <div class=\"panel"
Total in 633 ms
Error: Error building site: logged 1 error(s)

Eventually. Right now I dont have time to upgrade my theme . :slight_smile:

  <div id="collapse1" class="panel-collapse collapse {{ .Get "col" }} ">

Thank you, some how I missed a bracket…

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.