Skip to content
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 · 2 comments · Fixed by #2499
Closed

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

dmitriid opened this issue Sep 27, 2016 · 2 comments · Fixed by #2499
Assignees
Milestone

Comments

@dmitriid
Copy link
Contributor

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 Self-closing syntax and parameters throw error: unclosed shortcake 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 as completed in #2499 Sep 27, 2016
bep added a commit that referenced this issue Sep 27, 2016
@dmitriid
Copy link
Contributor Author

You rock!

tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
@github-actions
Copy link

github-actions bot commented Apr 2, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants