kisik21
1
I’m trying to implement a shortcode, but Hugo refuses to use it with an error:
ERROR 2017/09/28 18:25:02 shortcodes/list.html : template: shortcodes/list.html:1: bad character U+007B '{'
The shortcode template in question is:
{{ range $.Site.Data.{{ .Get "path" }}.{{ .Get "item" }} }}
* {{ . }}
{{ end }}
Just a test shortcode, nothing seems wrong, I’m just trying to import a dataset into a page… can someone help me with this?
bep
2
Try:
{{ range index (index $.Site.Data .Get "path" ) ( .Get "item") }}
The above totally untested, but it should show my intent.
kisik21
3
Wow, this works! Can you explain this magic please?
By the way, another error, but this is me doing something wrong probably…
ERROR 2017/09/28 19:02:18 error processing shortcode "shortcodes/list.html" for page "testing.md": template: shortcodes/list.html:1:34: executing "shortcodes/list.html" at <.Get>: wrong number of args for Get: want 1 got 0
The code:
{{% list path="discography" item="discography" %}}
Edit: Found a solution myself - wrong parentheses in shortcode sourcecode.
{{ range index (index $.Site.Data ( .Get 0 ) ( .Get 1 ) ) }}
bep
4
Please read the documentation.