Live data from Hacker News

Pure python html templating using with statements

gist.github.com

21–24 of 24 posts

Re: Pure python html templating using with statements

#21
This is very interesting, I had the exact idea for the longest time but never got time to fully implement it fully, here is my simple version of it https://github.com/Doboy/Dopy Do.py was the file with the implementation and basic.py is an example input. I am extremely interested in where this project goes and would like to get involved.

Re: Pure python html templating using with statements

#22
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…

I am confused how these are "faster" than other templating languages, such as Mako. Don't all of the better templating languages "compile to bytecode"? It would seem that the large number of function calls that would be involved per tag would massively decrease the performance vs. something that was able to treat most of the content as opaque.

Re: Pure python html templating using with statements

#23
post #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())

I've been playing with a similar syntax: https://github.com/maplambda/py-htmlout/blob/master/htmlgen.... I need to provide better examples, tests and form handling. I'm finding it nice to work with.

Looks good. My own module of this sort auto-escapes HTML special characters in strings fed to it, by default -- it looks like yours doesn't do this, at least at first glance. Is that right?

OTOH I think I like your syntax better.

Re: Pure python html templating using with statements

#24

Earlier quoted context omitted.

I've been playing with a similar syntax: https://github.com/maplambda/py-htmlout/blob/master/htmlgen.... I need to provide better examples, tests and form handling. I'm finding it nice to work with.

Looks good. My own module of this sort auto-escapes HTML special characters in strings fed to it, by default -- it looks like yours doesn't do this, at least at first glance. Is that right? OTOH I think I like your syntax better.

Thanks, that would be a good approach, mine is currently very barebones! just trying to get the syntax right and get a feel for using it in actual projects - hope to put up a real sample soon.
Post reply on HN