This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

collective.templateengines is an template engine abstraction layer for Python. It defines generic Zope interfaces for communicating with various Python template engines to achieve higher code reuse value.

This package is still much in development. All contributions and comments are welcome.

Features

collective.templateengines helps you to achieve

  • Easy, pluggable, template language switching. Write template tag code only once and use it across all template engines using abstracted tag plug-ings
  • Clean your codebase from template engine dependencies
  • Generic error and warning reporting mechanism across template engines
  • EGG deployment and easy_install support from PyPi repository
  • Interfaces defined using standard Zope interfaces package
  • Backends for Django template Language, Cheetah and Jinja2
  • Unit tests

Motivation

All template engines have their shortcomings. Sooner or later you want to try yet another engine, or someone else wants to use another template engine within your project. This package is aimed to make that transition as smooth as possible.

Installation

  • Install collective.templateengines egg
  • Install any of following template engine eggs: Django, Jinja2, Cheetah

Usage

Please take a look on collective.easytemplate package how to support switching between template engines and registering tags for them.

The following example shows how one can switch between Django and Cheetah template engines with one line of change. Naturally, the templates themselves need to be refactored.

Cheetah:

from collective.templateengines.backends import cheetah

engine = cheetah.Engine()
context = DictionaryContext({"foo":"bar"})
template, syntax_errors = engine.loadString("Show variable $foo", False)
result, evaluation_errors = template.evaluate(context)

Django:

from collective.templateengines.backends import djangotemplates

engine = djangotemplates.Engine()
context = DictionaryContext({"foo":"bar"})
template, syntax_errors = engine.loadString("Show variable {{ foo }}", False)
result, evaluation_errors = template.evaluate(context)

Tags

collective.templateengine uses term tag to refer to functions which you can use in the template engine context. In the future tags are indended to be expanded to cover template language structures as well.

collective.templateengines does not come with any tags out of the box. To define tags, I recommend you to take a look on collective.easytemplate package.

  • Tags provide collective.templateengines.interfaces.ITag interface
  • Tags are registered to the template engine using Engine.addTag() function.

Problems

  • Cheetah architecture lacks separate exposed compiling and evaluating phases
  • Cheetah exposes the full Python namespace to templates by default, making it hard to secure it
  • Cheetah cannot traverse Zope functions or attributes

Examples

Python Template Engines is used in

Changelog

0.3.5 (2013-05-07)

  • first import for plone 4.3 [vangheem]

0.3.2 - 0.3.4

  • Fixed various problems when context or HTTP request was not available or they were “special” in Plone templates [miohtama]
  • Fixed compatibility issues with LinguaPlone [miohtama]

0.3.1 - 0.3.2

  • Fixed unicode problems with Archetypes accessors
  • Documentation clean ups

0.3.0 - 0.3.1

  • Fixed problem in plone.py with problematic Archetypes schema fields

0.1.1 - 0.3.0

  • Major rework

0.1 - 0.1.1

  • Fixing PyPi deployment problems

0.1

  • Initial release
Release History

Release History

0.3.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
collective.templateengines-0.3.5.zip (25.9 kB) Copy SHA256 Checksum SHA256 Source May 7, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting