Hacker News new | past | comments | ask | show | jobs | submit login

             ["head", ["title", "HeRF Demo"]],
             ["body",
              ["div", {"id": "content"},
               ["h1", "HeRF - The HTML Rendering Framework"],
               ["hr"],
This seems almost as painful as writing out html.



It's almost exactly like writing out HTML. The advantages are that you're writing something that your editor and your program can understand. The editor can highlight things appropriately, the program can insert or delete html easily since you've encoded it as a standard data structure.

Also, you may not have noticed that even though it can handle the data in tuples, if you write it in list form (as in your comment), it's trivial for a program to add extra items enclosed in a particular tag. So if I have:

   x = ["ul"]
I can just append elements to x to fill out the list:

   for i in range(10): x.append(["li", "Item %s" % i])
However, I don't think that it's _quite_ as painful as writing HTML... You don't have to worry about closing tags, for instance. That said, I really wish Python could deal with barewords in data structures, because that would really clean it up otherwise.


Interesting you say that. I'm fleshing out a design that uses a similar syntax - In python:

(html, (body, (h1, "header one text") ) )

To me it's certainly not as painful as writing out html. I'm still working on it - hope to have a demo soon but its not a high priority, more something to sketch in the notebook when bored.

I have wondered if anyone would be interested in a templating syntax like this and got some response from the python mailing list -enough response to determine it's worth pursuing.

Its for personal projects so the designer seperation isn't a concern - I perfer to be able to generate it by code.


I think this sorta thing is more data-structure-ey than code-ey.




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

Search: