The Future

Brevé 2.0 will be compatible with Brevé 1.x at the template level, but the API is going to change in a backwards-incompatible way and the feature-set will grow. This won't mean a loss in performance or simplicity, just a growth in flexibility and features.

What's wrong with Brevé 1.x

Here's the current method for using a Brevé Template:

from breve import Template
from breve.tags.html import tags

vars = { }
t = Template ( tags )
t.render ( 'index', vars )

On the surface this appears simple enough. However, it falsely separates arguments across two interfaces. Template objects are only safe for a single usage, so there's no particular reason to not pass the arguments normally passed to render() to the Template during instantiation.

Secondly, Template.render() wraps two separate concerns into a single method: evaluation and flattening. This has the unintended consequence of not giving the programmer access to the evaluated Brevé DOM prior to flattening.

Brevé 1.1.8 introduces a new method, Tag.walk(). Unfortunately this method isn't usable on a Template object because there's no easy way to get access to the DOM. It's not available after instantiation and once it is available, it's immediately flattened and the process is over.

To address this, Brevé 2.0 will refactor the template creation process as follows:

t = Template ( 'index', vars, tags )
t.render ( )

Template will now have an attribute DOM that will allow the programmer to traverse and modify it prior to calling render(). Also it will have a walk() method that will simplify this:

def callback ( tag, is_tag ):
    print tag

t = Template ( 'index', vars, tags )
t.walk ( callback )
t.render ( )

Other New Features

soup2html is a tool provided with Brevé that allows you to convert an HTML document into Brevé source. This is useful but limits you to generating text, so it's mostly useful for converting a legacy site or files to Brevé source. Brevé 2.0 will provide a method for converting XML text into an actual Brevé DOM on the fly. This will allow things like pulling XML from a remote site (i.e. an RSS feed), turning it into a Brevé DOM, traversing it with walk(), making changes and then flattening it, or even attaching it to another Brevé DOM (i.e. your main site).

edit page
Back to top
Rendered using Brevé 1.3.0Copyright © 2007, Cliff Wells