[Django]-Is there a HAML implementation for use with Python and Django

38👍

You might be interested in SHPAML:

http://shpaml.com/

I am actively maintaining it. It is a simple preprocessor, so it is not tied to any other tools like Genshi. I happen to use it with Django, so there is a little bit of Django support, but it should not interfere with most other use cases.

21👍

I’d check out GHRML, Haml for Genshi. The author admits that it’s basically Haml for Python and that most of the syntax is the same (and that it works in Django). Here’s some GHRML just to show you how close they are:

%html
  %head
    %title Hello World
    %style{'type': 'text/css'}
      body { font-family: sans-serif; }
    %script{'type': 'text/javascript', 'src': 'foo.js'}

  %body
    #header
      %h1 Hello World
    %ul.navigation
      %li[for item in navigation]
        %a{'href': item.href} $item.caption

    #contents
      Hello World!

21👍

i’m looking for the same. I haven’t tried it, but found this:

http://github.com/jessemiller/HamlPy

👤Roger

7👍

You may be interested in Plim. It’s a mature python port of Slim.

4👍

This doesn’t actually answer your question, but the CSS component of HAML, SASS, can be used freely with any framework. I’m using it right now with Django.

3👍

I’m not sure what the status is of the GHRML bit as I only recently was looking into it. Can’t find a repo for it, original developer doesn’t have time for it anymore and maintenance was picked up by someone else with an interest in the project. Any extra info on this would be helpful.

Unfortunately, as these things go, I started writing my own HAML style processor 😉

http://dasacc22.wordpress.com/2010/05/03/python-implementation-of-haml/

It’s in no way fit for production use at the moment (its literally a 4 day old infant now but like 60+hours crammed in those 4 days) but anyone interested may check it out here. It has a range of features already implemented that make it useful as a toy, and as I clean up the codebase over the next week, I hope to see it replace all my custom XSLT/xpath extensions and templates I have.

3👍

My project, PyHAML, is a Mako preprocessor that gives you very HAML-like syntax. Some of the Ruby doesn’t translate very well to Python, so there are some differences, but the spirit is the same.

3👍

I ran across jade doing some node.js work and when returning to Django was looking for something similar. I found Pyjade and while it’s nearly exactly what I’m looking for it handles errors and debugging rather poorly within Django.

2👍

I just made this http://github.com/fitoria/django-haml it’s still in very early stage but it works.

2👍

Daniel Skinner’s project (mentioned above) seems to have been renamed to DMSL. It seems very powerful, emulates HAML but allows you to use python functions, lambdas, comprehensions etc in it’s syntax: https://github.com/dasacc22/dmsl

2👍

I would use this one, it seems to be the most standard one: https://pypi.org/project/HamlPy3/0.83.0/

Assuming you’re using Python3, you shouldn’t haver any issues using it with Django, Flask or even standalone.

1👍

You may want to try Hypertag: a new indentation-based language for HTML templating, strongly inspired by HAML. Hypertag has very clean syntax, provides full Django integration and a number of advanced features: native custom tags, DOM manipulation, Python-like imports, complex expressions, filters, control blocks (for, if, try…) and more. See here:

Disclaimer: I’m the author, glad to help if any issues or questions arise.

Leave a comment