Skip to content

Template::HAML

The latest version of this documentation lives at https://gdonald.github.io/Template-HAML/.

The homepage for Template::HAML is https://github.com/gdonald/Template-HAML.

Synopsis

Template::HAML is an HTML Abstraction Markup Language (HAML) implementation for Raku, built on Raku Grammars. HAML lets you write HTML as an indentation-driven outline rather than as a sea of opening and closing tags.

Currently developed against Raku v6.d.

Example

example.haml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
%html
  %head
    %title Page Title
  %body
    %section.container
      %h1 Title
      %h2 Subtitle
      %p Content
      %ul
        %li Foo
        %li Bar
1
2
3
4
use Template::HAML;

my $html = HAML.render(:src(slurp 'example.haml'));
say $html;

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<html>
  <head>
    <title>Page Title</title>
  </head>
  <body>
    <section class='container'>
      <h1>Title</h1>
      <h2>Subtitle</h2>
      <p>Content</p>
      <ul>
        <li>Foo</li>
        <li>Bar</li>
      </ul>
    </section>
  </body>
</html>

Install

Template::HAML can be installed using the zef module installation tool:

1
zef install Template::HAML