Skip to content
a haml compiler in python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


pyHaml is a python port of Haml, an HTML templating engine used primarily with Ruby on Rails. I'll refer to Ruby Haml as rHaml.

The goals of the project are to create a Haml templating engine that is

  1. pythonic
  2. flexible
  3. portable


In order to make pyHaml a bit more pythonic, most of the syntax evaluated as Ruby in rHaml is evaluated as python.

For example, the following rHaml code snippet:

%tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents

is written in pyhaml as:

%tagname{'attr1': 'value1', 'attr2': 'value2'} Contents

using python dict syntax rather than Ruby hash syntax.


pyHaml aims to be flexible and intuitive, allowing python to be evaluated inline as would be expected.

- def foo(i):
  %p = i ** 2
- for i in range(4):
  - foo(i)




pyHaml aims to run on both version 2.x and 3.x of python is a maintenance friendly manner. This is accomplished by monkey patching python upon starting execution.

Something went wrong with that request. Please try again.