Live data from Hacker News

Pure python html templating using with statements

gist.github.com

1–10 of 24 posts

Re: Pure python html templating using with statements

#3
My view is probably warped because I helped design the PTL "language" for Python. However, it's been my experience if you write well factored code (i.e. Don't-Repeat-Yourself, helper functions/macros), then templates that use the HTML by default mode end up looking extremely ugly. Essentially you end up with mostly Python logic with a little HTML markup mixed in.

It's not friendly to UI designers who like to load it into something like Dreamweaver or translate their static design into the template. I haven't thought of any good solution for that though. Zope TAL seemed like a valiant attempt but I'm sure how successful it was.

Re: Pure python html templating using with statements

#4
Weby Templates: http://www.jperla.com/blog/post/weby-templates-are-easier-fa...

Weby Templates are used in production on websites that have garnered over 500,000 uniques a month. They are incredibly easy to work with. They are the "templates for lazy people". They have 3 main benefits:

* easier * faster * more flexible

* The main codebase is implemented in 100 source lines of code.

* Extensive libraries only add just a couple hundred other lines of code.

* It is simple.

* It ensures that all tags have closing tags.

* It is compiled and fast.

* It is unicode compliant and safe.

* You can be fully fluent within 5 minutes since it is just Python and a transparent library.

http://www.jperla.com/blog/post/weby-templates-are-easier-fa...

Re: Pure python html templating using with statements

#5
post #4

Weby Templates: http://www.jperla.com/blog/post/weby-templates-are-easier-fa... Weby Templates are used in production on websites that have garnered over 500,000 uniques a month. They are incredibly easy to work with. They are the "templates for lazy people". They have 3 main benefits: * easier * faster * more flexible * The main codebase is implemented in 100 source lines of code. * Extensive libraries only add just…

Thanks, I didn't find that when searching. Very similar idea, but a slightly more involved syntax. I see it uses string building rather than a lib like lxml which probably makes it faster.

Re: Pure python html templating using with statements

#7
post #5
post #4

Weby Templates: http://www.jperla.com/blog/post/weby-templates-are-easier-fa... Weby Templates are used in production on websites that have garnered over 500,000 uniques a month. They are incredibly easy to work with. They are the "templates for lazy people". They have 3 main benefits: * easier * faster * more flexible * The main codebase is implemented in 100 source lines of code. * Extensive libraries only add just…

Thanks, I didn't find that when searching. Very similar idea, but a slightly more involved syntax. I see it uses string building rather than a lib like lxml which probably makes it faster.

This was the thread that I needed: http://hackerne.ws/item?id=1605909

Re: Pure python html templating using with statements

#9
post #7
post #5

Earlier quoted context omitted.

Thanks, I didn't find that when searching. Very similar idea, but a slightly more involved syntax. I see it uses string building rather than a lib like lxml which probably makes it faster.

This was the thread that I needed: http://hackerne.ws/item?id=1605909

Yea, my early iterations a few years ago looked more like your library does today. I learned a lot about building good APIs through experimentation.

Re: Pure python html templating using with statements

#10
Here is a simple idea:

  html(
    head(
      title('This is the title')),
    body(
      div(id='header', body=...)))
We could also create a shortcut for div ID and classes.. for instance a keyword capitalized is an ID, or something starting with _ could be a class.

It could then be possible to make "custom" fields:

html( headers(), left_side(), content(), footer())

Post reply on HN