Skip to content

Conversation

@goncalotomas
Copy link
Contributor

Griffin supports nested layouts with a maximum depth of 10. The following setup is supported:

src/alpha.md

---
title: Nested Layouts
layout: bravo
---
I'm a page being rendered from a nested layout!

lib/layouts/bravo.eex

---
layout: charlie
version: 1.18
---
<h1>Running from <%= @language %> v<%= @version %></h1>
<%= @content %>

lib/layouts/charlie.eex

---
language: Elixir
---
<html>
  <title><%= @title %></title>
<body>
  <p><%= @content %></p>
</body>
</html>

While this setup was supported, before this PR, the layout's frontmatter was only read for the layout field, meaning that we could not reference any other fields in layout files, not even the current layout.

After these changes this setup works as expected and produces the following HTML output for alpha.md:

<html>
  <title>Nested Layouts</title>
<body>
  <h1>Fun Times</h1>
  <h2>Running from Elixir v1.18</h2>
  <p>I'm a page being rendered from a nested layout!</p>
</body>
</html>

@goncalotomas goncalotomas self-assigned this Mar 10, 2025
@goncalotomas goncalotomas merged commit cfaede1 into main Mar 10, 2025
1 check passed
@goncalotomas goncalotomas deleted the merge-nested-layout-assigns branch March 10, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants