No question he is reinventing web2py helpers. They look almost identical. 
In fact an acknowledgement would be in order. Web2py helpers have been 
around almost unchanged since Oct 2007.

I agree he is adding context managers. We did not create them not because 
we did not think about them but because we were supporting python 2.4 which 
does not have a with statement.

There is a problem with minima's syntax.
It can do

   with div.myclass: ....

but this means you cannot "myclass" be a name of a method or attribute of 
div. Also you cannot do

   with div#myid: .... 

so this tries use the css / haml syntax in Python but only partially 
succeed.

In web3py we have helpers.py which are almost identical to web2py helpers 
but faster and simpler. I just added contexts (it took 10 lines of code, 
pretty much the same as in minima's, I will post the code later today).

https://github.com/mdipierro/web3py/commit/41a5c0f7e47e87e2bafdb5bef1f85df562803d8d

It allows this:

from web3py helpers import tag
div, h1, p = tag.div, tag.h1, tag.p

with div(_class='test') as html:
    h1('title')
    p('hello world')
print html

I like it. It is slightly different from minima's but it will stay in. 
Perhaps we should backport it to web2py.

Massimo 

     

On Tuesday, 18 December 2012 03:04:10 UTC-6, Arnon Marcus wrote:
>
> Has anybody taken a look at this?
>
> http://tomerfiliba.com/blog/Hypertext/
>
> My first reaction was "oh my, the poor guy is reinventing the wheel that 
> already exists in web2py..."
> Then a friend of mine pointed out that:
> "
> ...context managers allow your code structure to correlate to the the 
> html layout, through nesting blocks. that's the key difference
> "
>
> Is he correct?
> Could this be implemented in web3py's HTML helpers?
>

-- 



Reply via email to