Breve 1.1.8

2 views
Skip to first unread message

Cliff Wells

unread,
Apr 7, 2008, 1:06:52 PM4/7/08
to breve-...@googlegroups.com
I'm going to release Breve 1.1.8 by the end of this week.

Here's a summary of changes I intend to have in place by then:

1) New documentation (almost done).
2) Tag multiplication or variation thereof (done but needs to be decided
whether to make it a method or an operator).
3) Tag.walk method (done but needs more testing).
4) Deprecate conditional tags (when, switch/case). (done).
5) UTF-8 conversion for all plain strings (almost done).

I think that about covers it. New features are being documented here
until the release:

http://breve.twisty-industries.com/documentation/experimental

Regards,
Cliff


Cliff Wells

unread,
Apr 7, 2008, 7:39:52 PM4/7/08
to breve-...@googlegroups.com

On Mon, 2008-04-07 at 10:06 -0700, Cliff Wells wrote:

> 3) Tag.walk method (done but needs more testing).

Also, this method is a first step down the road to having full DOM
manipulation, so I'm curious if anyone is interested in such features
(i.e. the ability to create a load a Breve template, then traverse the
DOM, find elements and modify them, delete elements, create new ones,
etc, prior to flattening).

For example (untested, obviously):

from breve.flatten import flatten
from breve.tags.html import tags
globals( ).update ( tags )

logged_in = False
username = None

template = html [
body [
div ( id='login-form', style='display:none;' ),
div ( id='content' )
]
]

def fill_login ( tag, is_tag ):
if tag.attrs.get ( 'id', None ) == 'login-form':
if logged_in:
tag.children.append (
form ( action = '/login' ) [
'username', input ( type = 'text', name = 'username' ),
'password', input ( type = 'password', name = 'password' ),
input ( type = 'submit', value = 'submit' )
]
)
else:
tag.children.append (
span ( id = 'hello-user' ) [ 'Hello %s' % username ]
)
tag.attrs.style = "display: ''"
return False

template.walk ( fill_login, tags_only = True )
print flatten ( template )


Regards,
Cliff

Cliff Wells

unread,
Apr 7, 2008, 8:01:41 PM4/7/08
to breve-...@googlegroups.com

On Mon, 2008-04-07 at 16:39 -0700, Cliff Wells wrote:
>
> On Mon, 2008-04-07 at 10:06 -0700, Cliff Wells wrote:
>
> > 3) Tag.walk method (done but needs more testing).
>
> Also, this method is a first step down the road to having full DOM
> manipulation, so I'm curious if anyone is interested in such features
> (i.e. the ability to create a load a Breve template, then traverse the
> DOM, find elements and modify them, delete elements, create new ones,
> etc, prior to flattening).
>
> For example (untested, obviously):

Oops. Lots of errors. Well, now it's tested and works =)


from breve.flatten import flatten
from breve.tags.html import tags
globals( ).update ( tags )

logged_in = False
username = None

template = html [
body [
div ( id='login-form', style='display:none;' ),
div ( id='content' )
]
]

def fill_login ( tag, is_tag ):
if tag.attrs.get ( 'id', None ) == 'login-form':

if not logged_in:


tag.children.append (
form ( action = '/login' ) [
'username', input ( type = 'text', name = 'username' ),
'password', input ( type = 'password', name = 'password' ),
input ( type = 'submit', value = 'submit' )
]
)
else:
tag.children.append (
span ( id = 'hello-user' ) [ 'Hello %s' % username ]
)

tag.attrs [ 'style' ] = "display: ''"
return False

template.walk ( fill_login, tags_only = True )
print flatten ( template )


<html>
<body>
<div style="display: ''" id="login-form">
<form action="/login">
username<input type="text" name="username"></input>
password<input type="password" name="password"></input>
<input type="submit" value="submit"></input>
</form>
</div>
<div id="content"></div>
</body>
</html>


I'm still unsure of how useful this would be in real life, but I assume
it would be useful to someone, and the cost to everyone else is nil.

Regards,
Cliff

cbrain

unread,
Apr 10, 2008, 4:28:20 PM4/10/08
to brevé template engine
Hello Cliff,

This sounds very useful to me. As you stated, the cost to people who
don't want to use it is nil, and there is certainly potential for
people who do want this kind of stuff, so yes, please, let's have it!

--
Sven
Reply all
Reply to author
Forward
0 new messages