Getting error to access custom data via shortcode

Hi,

I have a Data file data/favorite/player.toml

player_list = [
  "AB devilliers",
  "Sachin Tendulkar",
  "Ricky Ponting",
  "Jacques Kallis",
  "Rahul Dravid",
  "Brian Lara"
]

I want to access this list in shortcode as

<select class="form-control">
  {{ range $.Site.Data.favorite }}
     {{ range .player_list }}
       <option>{{ . }}</option>
     {{ end }}
  {{ end }}
</select>

Why it is throwing errors

ERROR: 2015/10/08 error processing shortcode shortcodes/form.html 
 ERR: template: shortcodes/form.html:37:24: executing "shortcodes/form.html" at <$.Site.Data.favorite>: Site is not a field of struct type *hugolib.ShortcodeWithPage
1 Like
{{ range $.Page.Site.Data.favorite }}

Once again thanks @bep

Does hugo support like a hash inside .toml ?
I want to define inside toml and want to iterate in template using $key $value

You can have maps in TOML, yes. Have a look at the TOML spec.