Codegen
=======

The ``Codegen`` module is responsible for the low-level compilation
of the page template.

Suite
-----

The ``Suite`` class compiles a source code suite and makes a code
object available.

  >>> from chameleon.core.codegen import Suite
  >>> suite = Suite("""\
  ... print 'Hello World!'
  ... """)
  >>> exec suite.code in suite._globals
  Hello World!

Syntax extension: Dictionary lookup using dot operator
------------------------------------------------------
  
We allow attribute access to dictionary entries to minimize verbosity
in templates. It works by wrapping the get attribute nodes in a method
that tries a dictionary lookup if attribute lookup failed.

  >>> suite = Suite("""\
  ... a = {'b': 1}
  ... assert a['b'] == a.b
  ... """)
  >>> exec suite.code in suite._globals

Syntax extension: Dynamic scoping
---------------------------------

  >>> suite = Suite("""\
  ... _scope = {'a': 1}
  ... assert a == 1
  ... """)
  >>> exec suite.code in suite._globals
