Monday, 15 June 2015

yaml - Undefined method MiddlemanCore Data -



yaml - Undefined method MiddlemanCore Data -

i'm working on static site using middleman , trying utilize mm's local info functionality.

currently have required info directory within source directory of middleman project.

inside info directroy yaml file (home.yml)

here's construction of file:

slides: - image: "/img/slider/slide1.jpg" image_alt: "slide 1 alt text" caption: "slide 1 caption" - image: "/img/slider/slide2.jpg" image_alt: "slide 2 alt text" caption: "slide 2 caption"

i'm trying loop through slides in html.erb file so:

<%= data.home.slides.each |s| %> <figure class="slide"> <%= image_tag(s[:image], alt: s[:image_alt]) %> <figcaption><%= s[:caption] %></figcaption> </figure> <% end %>

but middleman spits nomethoderror on compiled html file.

undefined method `home' #<middleman::coreextensions::data::datastore:0x4383918>

i don't know i'm doing wrong. tried moving info directory level outside of source folder did nothing.

it seems middleman doesn't recognise home.yml folder in side info directory. help much appreciated i've found there's not much in way of documentation or back upwards middleman's info functionality.

you pretty close -- had minor typo. note how removed equals "=" sign.

change line:

<%= data.home.slides.each |s| %>

to this:

<% data.home.slides.each |s| %>

the next markup should generated 1 time done:

<figure class="slide"> <img alt="slide 1 alt text" src="/img/slider/slide1.jpg"> <figcaption>slide 1 caption</figcaption> </figure> <figure class="slide"> <img alt="slide 2 alt text" src="/img/slider/slide2.jpg"> <figcaption>slide 2 caption</figcaption> </figure>

yaml erb middleman

No comments:

Post a Comment