New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-closing syntax and parameters throw error: unclosed shortcode #2498

Closed
dmitriid opened this Issue Sep 27, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@dmitriid
Contributor

dmitriid commented Sep 27, 2016

Here's the code for image shortcode:

{{- $author := .Get "author" -}}
{{- $description := .Get "description" -}}
{{- $src := .Get "src" -}}
{{- $link := .Get "link" -}}
<figure class="image">
  <img src="{{ $src }}"{{ with $description }} alt="{{ . }}"{{ end }} />
  {{- if $description | or $author | or (gt (len .Inner) 0) -}}
  <figcaption>
    <cite>
      {{ if gt (len .Inner) 0 }}{{ .Inner }}{{ end }}
      {{ with $author }}{{ if $link }}<a href="{{ $link }}">{{ end }}{{ . }}{{ if $link }}</a>{{ end }} {{ end }}{{ with $description }}<em>{{ . }}</em>{{ end }}
    </cite>
  </figcaption>
  {{- end -}}
</figure>

Here's the code that throws errors:

{{< image src="https://c1.staticflickr.com/9/8426/29316998152_07355d7b6b_z.jpg" author="Joao" description="Hear me roar" link="twitter.com" />}}

{{< image src="https://c1.staticflickr.com/9/8426/29316998152_07355d7b6b_z.jpg" author="Joao" description="Hear me roar" link="twitter.com" />}}

The first usage of the shortcode will throw:

ERROR: 2016/09/27 15:25:56 shortcode.go:284: in-vino-veritas:73: unclosed shortcode

Replace the above with:

{{< image src="https://c1.staticflickr.com/9/8426/29316998152_07355d7b6b_z.jpg" author="Joao" description="Hear me roar" link="twitter.com" >}}{{</ image >}}

{{< image src="https://c1.staticflickr.com/9/8426/29316998152_07355d7b6b_z.jpg" author="Joao" description="Hear me roar" link="twitter.com" />}}

And it works. However, adding anything after the last shortcode will lead to the same issue, and it, too, will need a {{</ image >}}

@dmitriid dmitriid changed the title from Self-closing syntax and parameters throw error: unclosed shortcake to Self-closing syntax and parameters throw error: unclosed shortcode Sep 27, 2016

@bep bep added the Bug label Sep 27, 2016

bep added a commit to bep/hugo that referenced this issue Sep 27, 2016

@bep bep added this to the v0.17 milestone Sep 27, 2016

@bep bep closed this in #2499 Sep 27, 2016

bep added a commit that referenced this issue Sep 27, 2016

@dmitriid

This comment has been minimized.

Contributor

dmitriid commented Sep 27, 2016

You rock!

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment