Getting crazy with the local data

Hello there,

Apologies if this questions sounds silly, but I’m new to MiddleMan.

I’ve tried several examples now, some of them from some respected authors in this forum (active members that definitely know what they are talking about), but I can’t get the local data working as it should.

I created a simple file like /data/list.yml whose content is

links:
  - http://linka.com
  - http://linkb.com
  - http://linkc.com

but when I try to access to my collection from the /links.html.haml using the following code, the compilet

 %ul
   - data.list.links.each do |l|
       %li= link_to l, l

the compiler return the following error

error  build/features/index.html undefined method `list' for # <Middleman::CoreExtensions::Data::DataStore:0x007fdcfd39ca60>

I am not sure what’s wrong, and not sure whether the “local data” feature need to be somewhat activated?

Thanks for your help.

The error message is telling you what’s wrong. There is not a list method to operate on the data object. You’re correct in thinking of your data as a list but you don’t need to explicitly declare it as such.

data represents the yml files you drop into the /data directory
list refers to the name of your specific file

So what you need is

%ul

  • data.links.each do |l|
    %li= link_to l, l

Well, the real problem was the misplacent the data folder. I thought this should have been nested underneath the /source folder, whereas it comes at the same level.