middleman: passing local data variables between layout and template

Middleman is a great tool for creating static websites. Recently I've been using it to redesign my own website and a scenario I encountered was wanting to pass variables between my layout and my template file. Specifically, I wanted to pass information local data (a yaml file) to my layout file. Here's how I went about doing this: # in your layout file (inside layout/ folder): <% myvar = yield_content :myvar %> # in your template file (e.g., mypage.html.erb): <% content_for :myvar, data.somefile %> # this examples assumes there's a somefile.yml in your data/…Read more …