About Brevé
/images/breve-download.png

Brevé is a Python template engine that is designed to be clean and elegant with minimal syntax. Brevé was heavily inspired by Nevow Stan.

Like Stan (and unlike most Python template engines), Brevé is neither an XML parser nor PSP-style regex engine. Rather, Brevé templates are actual Python expressions. In popular parlance, Brevé is an internal DSL.

Unlike Stan, Brevé doesn't depend on Twisted or Nevow (it's a ground-up rewrite and has no external dependencies outside the Python Standard Library). Also Brevé is a full template engine, supporting concepts not found in Stan such as template inheritance, include files and simple conditionals. Brevé also drops support for a few Stan concepts that aren't strictly needed (e.g. patterns).

Brevé is relatively small, being around 300 lines of code for the engine proper, and around another 700 lines of code for the HTML entity and tag definitions.

Brevé supports the Buffet template engine API which means it works automatically with several frameworks, including Pylons, CherryPy and TurboGears. Brevé can also be used with Django or even standalone outside a framework.

A short example:

html [
    head [
        title [ 'A Brevé Template' ]
    ],

    body [
        h1 [ 'Briefly, Brevé' ], br,
        div ( style = 'text-align: center;' ) [
            span [ '''
                As you can see, Brevé maps very
                directly to the final HTML output.
            ''' ]
        ]
    ]
]

Key Features

  1. Remarkably terse syntax
  2. Pure Python - no markup or external parsers
  3. Pluggable XML tags - easily generate microformats or extend the provided HTML tags
  4. Define "flatteners" that directly map Python objects to formatted output
  5. Small codebase - easy to understand and extend
  6. Compatible with most major Python web frameworks
  7. Flexible inheritance mechanism
  8. Fast execution

Trifles

The Brevé name and logo are a play on the similarities between the word "Brevé" which is an espresso with half-and-half or skim milk, and the word "breve" which is a diacritical mark placed over vowels to indicate shortened enunciation and not coincidentally a root word suggesting terseness (e.g. brevity, abbreviated).

Brevé Needs a Maintainer!

I've decided to move away from Python as my language of choice and I'd like to see Brevé not get abandoned. If you are interested, please email me. I'm willing to continue hosting this site and the source code (or you can move it elsewhere) but I don't plan any further development (although I will happily accept patches until someone else takes over).

Please don't let this deter you from trying out Brevé. You don't need to worry about Brevé disappearing any time soon as I happen to have dozens of websites and clients that depend on it. Brevé is also fairly feature-complete so arguably adding new things to it might not be the best idea anyway.

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