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
> 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
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