About Brevé

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


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

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