Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm always impressed by Flask - especially its documentation. In fact, this seems like a good occasion to have a poke around and build something with it.

On a slightly related note - although jinja2 is already quite compact, I'm a fan of haml and I'm always surprised by the lack of support for it in Python. Is there something I'm missing? Uncanny valley for Pythonistas?



There's hamlish-jinja which is a preprocessor for haml-like[1] syntax for Jinja.

The project with the most traction seems to be HamlPy[2], but it's limited to Django templates.

The only generic implementation of Haml in Python that I'm aware of is PyHAML[3], but I have never used it.

[1] https://github.com/Pitmairen/hamlish-jinja [2] https://github.com/jessemiller/HamlPy [3] https://github.com/mikeboers/PyHAML


There's a Nemo[1] a "pythonic haml". It doesn't follow the Haml spec exactly, but rather tries to take the good parts and apply them to something suitable for Pythonistas.

It's built over Mako templates, so its faster and far more flexible than one built against the Django template markup.

[1] https://github.com/9cloud/Nemo


This is much better than what I found last time I went looking, thanks. I think I need to roll up my sleeves and dig deeper... Being able to mutate the templates to suit what I usually might build seems cool (but a big time sink!).


You can roll out your own or use one of the existing translators which translate from haml to jinja2 syntax.

Do you use slim templates? I recently wrote a hand rolled recursive decent parser which translates slim to jinja2 - https://github.com/thoughtnirvana/slimish-jinja2. Jinja2 supports extensions and after adding this extension, you can write slim templates which will be translated to jinja2 on the run.

The lexer and parser are simple enough - you can make code changes or roll out your own if you want to.


Interesting. Seems I haven't grasped the flexibility of jinja. I'll look into this, thanks.


There was a Haml-like language called GHRML a while back, but it seems to have disappeared. There is something like it called SHPAML: http://shpaml.webfactional.com/

Though I think Ruby has better markup libraries in general. For example, they have Nokogiri, which is an absolute joy to use for XML parsing. And implementations of Markdown and Textile with actual parsers, whereas Python Markdown and Python Textile are straight regex-using ports of the Perl/PHP versions. It's kinda sad really.


To learn Ruby I decided to redo my website in it, and I felt the complete opposite. I was surprised there's nothing comparable in the Ruby world to Jinja2 or Mako. Nothing supports blocks/macros or template inheritance, so I wrote my own small template engine in Ruby that does.


Check out Pantyshot/Upskirt for Markdown, it's worked out pretty well for me.


XML parsing: lxml (lxml.html is particularly wonderful).

Markdown/Textile; in the Python world people mostly use Restructured Text, not least because of its privileged position in docstrings.


python-markdown is in no way port of perl version. It's complete parser which can be extended and so on. But python-markdown2 is port of perl version, based on regexps instead of being real parser.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: