Haml Inherit Templates

Posted by kjfletch on Stack Overflow See other posts from Stack Overflow or by kjfletch
Published on 2010-06-02T21:26:35Z Indexed on 2010/06/02 23:04 UTC
Read the original article Hit count: 241

Filed under:
|
|

I'm using Haml (Haml/Sass 3.0.9 - Classy Cassidy) stand-alone to generate static HTML. I want to create a shared layout template that all my other templates inherit.

Layout.haml

%html
  %head
    %title Test Template
  %body
    .Content

Content.haml

SOMEHOW INHERIT Layout.haml
SOMEHOW Change the title of the page "My Content".
  %p This is my content

To produce:

Content.html

<html>
  <head>
    <title>My Content</title>
  </head>
  <body>
    <div class="Content">
      <p>This is my content</p>
    </div>
  </body>
</html>

But this doesn't seem possible. I have seen the use of rendering partials when using Haml with Rails but can't find any solution when using Haml stand-alone.

Having to put the layout code in all of my templates would be a maintenance nightmare; so my question is how do I avoid doing this? Is there a standard way to solve this problem? Have I missed something fundamental?

© Stack Overflow or respective owner

Related posts about html

Related posts about templates