announcement: SHPAML (alternative to haml)

70 views
Skip to first unread message

Steve Howell

unread,
Dec 19, 2009, 11:04:35 PM12/19/09
to Django users
Hi, I have ported some haml concepts to Python in my implementation of
SHPAML. Details here:

http://shpaml.webfactional.com/

For those of you not aware of haml, haml is a markup language
implemented in Ruby that allows you to eliminate end tags in HTML.
Like Python itself, haml and SHPAML use indentation to eliminate the
need for block-ending syntax. Whereas Python eliminates the end-
squiggly in scripting code, haml/SHPAML eliminates the need for end
tags in HTML. If you hate Python, you will undoubtedly hate haml and
SHPAML. If you like Python, you might like haml/SHPAML.

When I originally wrote SHPAML, I attempted to eliminate end tags in
my Django templates, such as endfor, endblock, endwith, and friends.
I decided to back off that strategy and just DRY up the HTML. So
SHPAML has no explicit support for Django now, other than letting
Django template constructs gently pass through the preprocessor.

But the whole SHPAML website is still written in Django. You can see
the markup here:

http://shpaml.webfactional.com/long_example

The Django markup for my website is now back to being lexically
repetitive, but that's okay. Removing all the crufty syntax of HTML
lets the Django syntax stand out more clearly.

If you are passionate about DRY markup, please join the mailing list
on the site above and help me evolve this product!

One thing you might like about SHPAML is that you can try before you
buy. Try it here:

http://shpaml.webfactional.com/try_it

Thanks,

Steve

Durbin

unread,
Dec 29, 2009, 4:44:42 PM12/29/09
to Django users
very cool! any plans to integrate it fully into the django templating
system?

Steve Howell

unread,
Jan 26, 2010, 6:10:11 AM1/26/10
to Django users
On Dec 29 2009, 1:44 pm, Durbin <neildur...@gmail.com> wrote:
> very cool! any plans to integrate it fully into the django templating
> system?

Glad you like it.

Amit Upadhyay has written a loader here:

http://github.com/amitu/dutils/blob/master/dutils/shpaml_loader.py

I've used shpaml mostly with django, but for my own use cases, I
prefer light integration, so I publish from shpaml to django outside
of django itself.

This is the script I use; it should be fairly straightforward to
modify it for more complicated template directory structure schemes:

from shpaml import convert_text
import os
import glob

def publish():
os.system('rm -f templates/*.html')
for fn in glob.glob('templates/*.shpaml'):
out_fn = fn.replace('.shpaml', '.html')
open(out_fn, 'w').write(convert_text(open(fn).read()))

if __name__ == '__main__':
publish()

If you are interested in shpaml, please join the mailing list here:

http://groups.google.com/group/shpaml

Since this announcement, there has been a port of shpaml to
Javascript. Thanks to the Javascript implementation, you can see a
WYSIWYG demo of shpaml here:

http://kp.hcoop.net/kp/doc/tip/shpaml/js/demo.html

Reply all
Reply to author
Forward
0 new messages