This package allows developing Nikola templates using Chameleon. Chameleon is a fast implementation of the Zope Page Templates specification. Unlike template systems such as Jinja2 or Mako, page templates are designed to be valid (X)HTML and may be edited in HTML editors. It’s even possible to use visual design tools to produce pages that are then relatively easily turned into page templates; sometimes it’s even possible to edit those templates again in the same visual design tool.
Page templates can be much more than that, though. When combined with the Zope component architecture (ZCA), they can be designed to be extensible and flexible in a way that the simple template inheritance schemes of other template systems cannot match. This package is designed to embrace that, making it possible to create and extend templates and themes very easily.
Although we believe the component architecture can be used to make
themes flexible and make changing and customizing them through
inheritance or configuration easier, you are not required to use
these features if you don’t want to. You can build an entire theme
just based on the files in the templates directory and the Chameleon
For a discussion of how the ZCA can be leveraged in your themes, see Leveraging the Component Architecture.
To create templates with this package, you’ll need a basic understanding of the following:
It may be helpful to understand object traversal, similar to what can be used in the Pyramid web framework.
We use zope.traversing to implement traversal, and provide several “path adapters” and views to make traversal in path expressions more convenient. For more information on those helpers, see Path Helpers.
Macros and Viewlets¶
Most templates will also make use of macros, and many will also use viewlets. We’ll discuss how each of these can be used to develop flexible templates in Using Macros and Using Viewlets, respectively. Complete examples using these techniques can be found in base-chameleon, and its extension using bootstrap3, bootstrap3-chameleon.
Your templates will have access to all of the template variables
These are made available in the
options dictionary, one of the
available to page templates. The
context standard name is often a
Nikola post object (or other Nikola object),
and the context-specific template variables are available through it.