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

"Bad character" for valid YAML keys #1474

Closed
gjtorikian opened this issue Oct 6, 2015 · 6 comments
Closed

"Bad character" for valid YAML keys #1474

gjtorikian opened this issue Oct 6, 2015 · 6 comments
Labels

Comments

@gjtorikian
Copy link

Supposing you have a YAML data file called commits.yml that looks like this:

about-commits: |
  Some words about commits.

Attempting to reference this data file in a template yields:

ERROR: 2015/10/05 template: layout.html:7: bad character U+002D '-'
ERROR: 2015/10/05 Error while rendering page guides/about-commits.md: html/template: "layout.html" is an incomplete template
@bep
Copy link
Member

bep commented Oct 6, 2015

This is a restriction of the Go template parser/lexer. Try to quote the key on the calling side. If that works, please close this issue. If you want hyphens unquoted in keywords in Go templates, please open an issue here:

https://github.com/golang/go/issues

@bep
Copy link
Member

bep commented Oct 9, 2015

Please reopen if you still believe there is something Hugo should do about this.

@severo
Copy link

severo commented Aug 27, 2018

Try to quote the key on the calling side

index . "about-commits"

https://stackoverflow.com/a/24629884/7351594

@marceloverdijk
Copy link

Sorry to hijack this one a bit.

I'm trying to quote on the calling side like:

{{ $tyre_manufacturer := index ".Site.Data.tyre-manufacturers" .Page.Params.tyre_manufacturer_id }}

but it gives: error calling index: cannot index slice/array with type string

Is there a way to access the data collection (tyre-manufacturers) with the hyphen in the name?

@danielcn
Copy link

The interesting about open source and collaboration is "when you're trying to solve your problem you can solve for others". The point is, I came here because of other different issues.

For your question @marceloverdijk I hope you solved this, in case not and to let register plese check it it can help you:
https://richmegginson.livejournal.com/28926.html

@github-actions
Copy link

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 Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants