On Nov 28, 4:46 am, "Colin W." <cjwilliam...@gmail.com> wrote: > On 27-Nov-09 22:04 PM, Steve Howell wrote: > > > > > Python has this really neat idea called indentation-based syntax, and > > there are folks that have caught on to this idea in the HTML > > community. > > > AFAIK the most popular indentation-based solution for generating HTML > > is a tool called HAML, which actually is written in Ruby. > > > I have been poking around with the HAML concepts in Python, with the > > specific goal of integrating with Django. But before releasing that, > > I thought it would be useful to post code that distills the basic > > concept with no assumptions about your target renderer. I hope it > > also serves as a good example of what you can do in exactly 100 lines > > of Python code. > > > Here is what it does... > > > You can use indentation syntax for HTML tags like table. > > > From this... > > > table > > tr > > td > > Left > > td > > Center > > td > > Right > > > ...you get this: > > ... > > [snip] > > This is a neat idea but would a two character indentation not be enough? >
The code actually preserves whatever indent style you give as input, as long as you are consistent. I used 4-space indents in my examples since that seems to be the convention in Python, but when I did my stint in Ruby, I got pretty comfortable with 2-space indents as well, and I think it can make sense for HTML, where you do get pretty deep sometimes with idioms like table/tr/td. -- http://mail.python.org/mailman/listinfo/python-list