Experimental Features

The SVN version of Brevé will often contain experimental features. These are features that are being considered for a future version of Brevé but are not considered ready. You are encouraged to test them and provide feedback, but please do not use them in production code as they are subject to change or complete removal.

Once again, these features are only here to solicit feedback and bug reports. Do not rely upon them to exist in the form documented here (or at all) in any release.

Conversely, if you like something you see here, please say so in the community forum. It will go a long way toward seeing it become a permanent feature.

Back to Main Documentation

AutoTag

An AutoTag is a simple class that returns a Tag object when an attribute is referenced:

from breve.tags.html import tags as html

t = Template ( html, autotags = 'T' )
t.render ( 'mytemplate' )

then if you have a template like:

T.foo ( attr='bar' ) [
    'this tag was auto-generated'
]

Note that "foo" never has to be declared. It is enough to simply reference it as an attribute of "T". The choice of "T" is arbitrary; any string that can be used as a Python identifier is valid.

The above would render as:

<foo attr="bar">this tag was auto-generated</foo>

AutoTag is available outside a template via breve.tags.AutoTag.

Stacks

Two new functions are available, push(**kw) and pop(key). These can be used to store values on a set of named stacks:

push ( a = 1, b = 2 ),

pop ( 'a' ), pop ( 'b' )

Simple Brevé Server

In the tools directory is a very simple WSGI server that is specialized for serving Brevé templates. It can also serve static files. This is not a production server by any means. It is simply meant to allow a user to preview Brevé templates in their browser without a lot of fuss:

$ breve_server -h

Usage: breve_server [options]

Options:
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  listen on port
  -b ADDRESS, --bind=ADDRESS
                        listen on interface
  -t PATH, --templates=PATH
                        location of templates
  -d PATH, --docroot=PATH
                        location of static files
  -i NAME, --index=NAME
                        default template to serve
  -n NAME, --namespace=NAME
                        namespace to use for variables
  -v PATH, --vars=PATH  Python module of template variables

For example:

$ breve_server -p 9999 -t tools/breve_server/templates \
        -d tools/breve_server/static -n v -v tools/breve_server/vars.py -i index

Now you can visit http://127.0.0.1:9999/ and see your Brevé template.

As of Brevé 1.2.2, breve_server is installed as a normal tool (usually in /usr/bin) so you can run it like any other program.

Pylons 0.9.7 Adapter

Pylons 0.9.7 has disposed of the Buffet adaptor and created its own way of dealing with template engines. This new method is quite simple and allows for maximum flexibility. To use Brevé with a Pylons 0.9.7 project, simply add the following to config/environment.py:

config [ 'pylons.app_globals' ].breve_opts = {
    'root': 'myapp/templates'
}

You can add as many Brevé-specific options as you like here. They will be passed to the Template object as instantiation arguments.

Next, you must use the Brevé adapter in your controller:

from breve.plugin.pylons_adapter import render

class MyController ( BaseController ):
    def index ( self ):
        c.message = 'hello, world'
        return render ( 'index' )

This is not the only way to render a Brevé template (you could create a new adaptor modeled after the one provided), but it's enough to get you started.

Back to Main Documentation

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