Git Product home page Git Product logo

chameleon's Introduction

Overview

Chameleon is an HTML/XML template language compiler.

The distribution comes with a complete template engine: Chameleon Page Templates [1].

There are no external library dependencies [2]. You can install it using setuptools or the newer distribute (recommended):

$ easy_install Chameleon

Formatted documentation is available.

Platform

This library has been successfully tested on the following platforms:

  • Python 2.5, 2.6, 2.7
  • Python 3.1, 3.2
  • PyPy

What's New in 2.x

The 2.x series is a complete rewrite of the library and supports both Python 2.5+ and Python 3.1+ with a single source code.

For most users it should be an easy upgrade, however note that at present, there is no engine for the Genshi language.

New parser

This series features a new parser, implemented in pure Python. It parses both HTML and XML inputs (the previous parser relied on the expat system library and was more strict about its input).

Language changes

The 2.x engine matches the output of the reference implementation more closely (usually exactly). There are less differences altogether; for instance, the method of escaping TALES expression (usually a semicolon) has been changed to match that of the reference implementation.

This series also introduces a number of new language features:

1) Support for the tal:on-error from the reference specification has been added.

2) Inspired by the Genshi language, a pair of new attributes has been added: tal:switch and tal:case, allowing flexible conditions.

Expression engine

The expression engine has been redesigned to make it easier to understand and extend.

The engine is built on the ast module (available since Python 2.6; backports included for Python 2.5).

Performance

The compiler output has been optimized for complex templates. For most applications, the engine should perform similarly to the 1.x series.

Very simple templates with tight loops (such as that of the "big table" benchmark) will see a decrease in performance. The compiler is optimized for dynamic variable scope and this lowers performance for templates that require only a static scope.

License and Copyright

This software is made available as-is under a BSD-like license [3] (see included copyright notice).

Notes

[1]The template language specifications and API for the Page Templates engine are based on Zope Page Templates (see in particular zope.pagetemplate). However, the Chameleon compiler and Page Templates engine is an entirely new codebase, packaged as a standalone distribution. It does require a Zope software environment.
[2]The string translation interface is based on the gettext library. Chameleon comes with built-in support for the zope.i18n package which includes a translation framework (internationalization). If this package is installed, it will be used as the default translation framework. It is trivial to provide a custom translation function, however.
[3]This software is licensed under the Repoze license.

chameleon's People

Contributors

malthe avatar hathawsh avatar oliora avatar

Stargazers

Bayle Shanks avatar

Watchers

Bayle Shanks avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.