Skip to content

Nested Layouts using YAML Frontmatter #251

jmulder opened this Issue Jan 26, 2012 · 10 comments

7 participants

jmulder commented Jan 26, 2012

I'd like to be able to nest layouts by defining them in Frontmatter. I know middleman 3.0 will be introducing a wrap_layout method, but I'd like to be consistent in the way I define layouts throughout the entire project.

Middleman member
tdreyno commented Jan 27, 2012

Can you post a step by step description of your proposal? Give an example YAML frontmatter?

jmulder commented Jan 28, 2012

It's exactly the same functionality as wrap_layout provides, except called from the Frontmatter.


layout: homepage

layout: master
<div id="homepage">
    <% yield %>

<!doctype html>
    <% yield %>

The simplest use-case would allow me to have a generic master layout that would likely include HTML for the HEAD along with some high level structural HTML, followed by a specific layout. A more interesting would be one that allowed me to include a partial that itself would include a layout.

I'd like to minimize the amount of logic surrounding the HTML, so allowing me to define this through the YAML Frontmatter would give me the benefit of consistency and the future possibility to parse this data.

Middleman member
tdreyno commented Jan 28, 2012

The difference between:

<% wrap_layout :master do %>
<% end %>


wrap_layout: master

Is pretty minimal. But shouldn't be difficult to implement. Actually seems to make a little more sense in the Frontmatter as it's metadata.

Middleman member
tdreyno commented May 9, 2012

Punting on this until 3.1

iwarner commented Apr 23, 2013

This is basically how Jekyll handles nested layouts +1 for this.


Yeah, this is what I was expecting when I first started using Middleman, in part because I'd used Jekyll. The existing process is fine, but using front-matter seems slightly better for most purposes. wrap_layout has some flexibility that front-matter doesn't have in terms of deciding exactly where to insert the layout wrapping, but for most purposes, I'd want it to be outermost anyway.

Middleman member
bhollis commented Apr 23, 2013

A pull request for this would be appreciated!


Would be really nice to be able to add some frontmatter to layouts in general, like for example css or arbitrary data like section, so then a template can inherit things from layout outside of straight html/erb type stuff.

Aupajo commented Mar 26, 2014

Is it possible to use YAML in layouts, then? How do you access the data?

Middleman member
bhollis commented Mar 26, 2014

No, it is not.

@tdreyno tdreyno closed this Jul 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.