Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A layout using another layout as a base #942

Open
elpiel opened this issue Dec 4, 2021 · 4 comments
Open

A layout using another layout as a base #942

elpiel opened this issue Dec 4, 2021 · 4 comments

Comments

@elpiel
Copy link
Contributor

elpiel commented Dec 4, 2021

Since I'm looking to replace jekyll with something that is built with Rust, I realised that it's not currently possible to have a layout that uses another layout.

I tried extracting the frontmatter for the layer and making a look when rendering the document, however, I was unable to make it work.

Is this something you'd like to have in cobalt?
I can open a draft PR if it is so.

@epage
Copy link
Member

epage commented Dec 4, 2021

Have you looked into using include to use snippets between these layouts?

My preference is to instead keep it simple, relying on composing using include but I'm up for hearing use cases to explain why layouts of layouts would be needed.

@ghost
Copy link

ghost commented Dec 5, 2021

Have you looked into using include to use snippets between these layouts?

I'm not OP but I can attest one of the greatest features of Hugo are layout inheritance. Without it it's not possible to build a DRY website or practice functional programming via composition in the UI.

@elpiel
Copy link
Contributor Author

elpiel commented Dec 5, 2021

Have you looked into using include to use snippets between these layouts?

My preference is to instead keep it simple, relying on composing using include but I'm up for hearing use cases to explain why layouts of layouts would be needed.

Yeah, this is what the default layout is doing, but the crates one extends it to add more stuff:

https://github.com/AeroRust/are-we-in-space-yet/blob/933b45db16c2585f68d2ce0c9a03640ad6604366/_layouts/crates.html

It's not mandatory to have this feature but it's good to have.

@epage
Copy link
Member

epage commented Dec 6, 2021

Can you help me understand why nested layouts are such a great feature?

To me

  • They make it hard to see whats happening, having to follow up through several layers of layouts
  • They seem restrictive in their reuse (all or nothing nesting)
  • They make creation of god layouts that handle all cases the easy path because of the above restriction. Its easier to say "just one more thing" than to refactor.

This is compared to a layout built of snippets where you pick and choose the descriptive reuse elements you want.

The one value I see in layouts is maintaining the balanced start/end together rather than having separate includes for start/end, much like RAII in C++ and Rust or with in Python. I can see us adding support for something that is a mix of Tera filter blocks and macros

{% define body content %}
<body>
{{ content }}
</body>
{% enddefine%}

{% body %}
Hello world!
{%endbody %}

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

No branches or pull requests

2 participants