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.
Can you post a step by step description of your proposal? Give an example YAML frontmatter?
It's exactly the same functionality as wrap_layout provides, except called from the Frontmatter.
<% yield %>
<% 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.
The difference between:
<% wrap_layout :master do %>
<% end %>
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.
Punting on this until 3.1
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.
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.
Is it possible to use YAML in layouts, then? How do you access the data?
No, it is not.