ANN: EmPy 3.0 -- Python templating system

Erik Max Francis max at alcyone.com
Sun Jun 1 21:12:20 EDT 2003


Summary

    A templating system for Python.


Overview

    EmPy is a system for embedding Python expressions and statements
    in template text; it takes an EmPy source file, processes it, and
    produces output.  This is accomplished via expansions, which are
    special signals to the EmPy system and are set off by a special
    prefix (by default the at sign, '@').  EmPy can expand arbitrary
    Python expressions and statements in this way, as well as a
    variety of special forms.  Textual data not explicitly delimited
    in this way is sent unaffected to the output, allowing Python to
    be used in effect as a markup language.  Also supported are
    callbacks via hooks, recording and playback via diversions, and
    dynamic, chainable filters.  The system is highly configurable via
    command line options and embedded commands.

    Expressions are embedded in text with the '@(...)' notation;
    variations include conditional expressions with '@(...?...!...)'
    and the ability to handle thrown exceptions with '@(...$...)'.  As
    a shortcut, simple variables and expressions can be abbreviated as
    '@variable', '@object.attribute', '@function(arguments)',
    '@sequence[index]', and combinations.  Full-fledged statements
    are embedded with '@{...}'.  Control flow in terms of conditional
    or repeated expansion is available with '@[...]'.  A '@' followed
    by a whitespace character (including a newline) expands to
    nothing, allowing string concatenations and line continuations.
    Comments are indicated with '@#' and consume the rest of the line,
    up to and including the trailing newline.  '@%' indicate
    "significators," which are special forms of variable assignment
    intended to specify per-file identification information in a
    format which is easy to parse externally.  Escape sequences
    analogous to those in C can be specified with '@\...', and finally
    a '@@' sequence expands to a single literal at sign.


Getting the software

    The current version of empy is 3.0.

    The latest version of the software is available in a tarball here:
    http://www.alcyone.com/pyos/empy/empy-latest.tar.gz.

    The official URL for this Web site is
    http://www.alcyone.com/pyos/empy/.


Requirements

    EmPy should work with any version of Python from 1.5.2 onward.  It
    has been tested with all major versions of CPython from 1.5 up,
    and Jython from 2.0 up.  The included test script is intended to
    run on UNIX-like systems with a Bourne shell.


License

    This code is released under the GPL.

...

Control [new in EmPy 3.0]

    EmPy version 3 and above includes the ability to direct
    conditional and repeated expansion of blocks of EmPy code with
    control markups (the obsolescent "substitution" markups are
    unavailable as of version 3.0).  Control markups have analogs to
    control flow structures in Python such as 'if/elif/else', 'for', and
    'while'.  Control markups are set off with the '@[...]' notation.

    Control markups are designed to be used in precisely the same way
    that their internal Python analogues are used, except that the
    control markups are intended to be used where there is much more
    markup than control structure.

    Some control markups are considered "primary," (*e.g.*, 'if',
    'for', 'while') as they begin a control markup.  Others are
    considered "secondary," since they can only appear inside control
    flow markups delineated by primary markups (*e.g.*, 'elif',
    'else', 'continue', 'break').

...

Release history [since 2.3]

    - 3.0; 2003 Jun 1.  Control markups with '@[...]'; remove
      substitutions (use control markups instead); support
      '@(...?...!...)' for conditional expressions in addition to the
      now-deprecated '@(...?...:...)' variety; add acknowledgements
      and glossary sections to documentation; rename buffering option
      back to -b; add -m option and 'EMPY_PSEUDO' environment variable
      for changing the pseudomodule name; add -n option and
      'EMPY_NO_OVERRIDE' environment variable for suppressing
      'sys.stdout' proxy; rename main error class to 'Error'; add
      standalone 'expand' function; add --binary and --chunk-size
      options; reengineer parsing system to use Tokens for easy
      extensibility; safeguard curly braces in simple expressions
      (meaningless in Python and thus likely a typographical error) by
      making them a parse error; fix bug involving custom Interpreter
      instances ignoring globals argument; distutils support.


-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Forever we / Infinitely
\__/  Sandra St. Victor




More information about the Python-list mailing list