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

Are nested layouts possible? #119

Open
robertwbradford opened this issue Feb 11, 2016 · 2 comments
Open

Are nested layouts possible? #119

robertwbradford opened this issue Feb 11, 2016 · 2 comments

Comments

@robertwbradford
Copy link

Hello, I'm wondering if there is a way to nest layouts. I see in the express-hbsengine you can have something like the following:

layouts/site.hbs

<!DOCTYPE html>
<html>
  <head>
    <!-- common head things -->
  </head>
  <body>
    {{{body}}}
  </body>
</html>

layouts/with-header-footer.hbs

{{!< site }} {{!-- here's the magic --}}
<header class="site-header">...</header>
{{{body}}}
<footer class="site-footer">...</footer>

In layouts/with-header-footer.hbs, the {{!< site }} means you get everything also wrapped in the site layout. This approach helps to DRY things up when your site uses multiple layouts. Is something like this currently available? Is there a better approach?

@dsvaughan
Copy link

I would like to see this feature as well!

@BokChoyWarrior
Copy link

BokChoyWarrior commented May 10, 2021

Me too, although maybe there is a way of editing the helper functions inside https://github.com/pillarjs/hbs/tree/master/examples/extend to accommodate this feature?

I would also like to see an example of using a default block with the above example, if possible.

To update, Jinja2 (a python templating engine) has a brilliant template inheritance system. Details in the jinja2 docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants