summaryrefslogtreecommitdiff
path: root/docs/narr
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-09-26 06:42:53 +0000
committerChris McDonough <chrism@agendaless.com>2008-09-26 06:42:53 +0000
commit01a6e567a20096f6033cc603667f4e900d2a44c3 (patch)
treea87431383a63dbafbb5cccdfa7679b9187bdfc29 /docs/narr
parent26216e5526ca56d886d2348f9e1f09b86622aa72 (diff)
downloadpyramid-01a6e567a20096f6033cc603667f4e900d2a44c3.tar.gz
pyramid-01a6e567a20096f6033cc603667f4e900d2a44c3.tar.bz2
pyramid-01a6e567a20096f6033cc603667f4e900d2a44c3.zip
Move to Chameleon.
Diffstat (limited to 'docs/narr')
-rw-r--r--docs/narr/MyProject/myproject/views.py2
-rw-r--r--docs/narr/project.rst36
-rw-r--r--docs/narr/templates.rst42
3 files changed, 45 insertions, 35 deletions
diff --git a/docs/narr/MyProject/myproject/views.py b/docs/narr/MyProject/myproject/views.py
index 6e1be6190..67dbd00b6 100644
--- a/docs/narr/MyProject/myproject/views.py
+++ b/docs/narr/MyProject/myproject/views.py
@@ -1,4 +1,4 @@
-from repoze.bfg.template import render_template_to_response
+from repoze.bfg.chameleon_zpt import render_template_to_response
def my_view(context, request):
return render_template_to_response('templates/mytemplate.pt',
diff --git a/docs/narr/project.rst b/docs/narr/project.rst
index 7360053dd..3bca363e8 100644
--- a/docs/narr/project.rst
+++ b/docs/narr/project.rst
@@ -299,7 +299,7 @@ your application by requiring more settings in this section.
The ``reload_templates`` setting in the ``[app:main]`` section is a
:mod:`repoze.bfg`-specific setting which is passed into the framework.
-If it exists, and is ``true``, :term:`z3c.pt` and XSLT template
+If it exists, and is ``true``, :term:`Chameleon` and XSLT template
changes will not require an application restart to be detected.
.. warning:: The ``reload_templates`` option should be turned off for
@@ -418,8 +418,8 @@ The ``myproject`` :term:`package` lives inside the ``MyProject``
#. A ``run.py`` module, which contains code that helps users run the
application.
-#. A ``templates`` directory, which is full of :term:`z3c.pt` and/or
- :term:`XSLT` templates.
+#. A ``templates`` directory, which contains :term:`Chameleon` (or
+ other types of) templates.
#. A ``tests.py`` module, which contains unit test code for the
application.
@@ -485,16 +485,17 @@ in the model, and the HTML given back to the browser.
dispatch`). The *request* is an instance of the :term:`WebOb`
``Request`` class representing the browser's request to our server.
-#. The view renders a :term:`template` and returns the result as the
- :term:`response`. Note that because our ``MyProject.ini`` has a
- ``reload_templates = true`` directive indicating that templates
- should be reloaded when they change, you won't need to restart the
- application server to see changes you make to templates. During
- development, this is handy. If this directive had been ``false``
- (or if the directive did not exist), you would need to restart the
- application server for each template change. For production
- applications, you should set your project's ``reload_templates`` to
- ``false`` to increase the speed at which templates may be rendered.
+#. The view renders a :term:`Chameleon` template and returns the
+ result as the :term:`response`. Note that because our
+ ``MyProject.ini`` has a ``reload_templates = true`` directive
+ indicating that templates should be reloaded when they change, you
+ won't need to restart the application server to see changes you
+ make to templates. During development, this is handy. If this
+ directive had been ``false`` (or if the directive did not exist),
+ you would need to restart the application server for each template
+ change. For production applications, you should set your project's
+ ``reload_templates`` to ``false`` to increase the speed at which
+ templates may be rendered.
.. note::
@@ -569,16 +570,15 @@ without the PasteDeploy configuration file:
``templates/mytemplate.pt``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The single :term:`template` in the project looks like so:
+The single :term:`Chameleon` template in the project looks like so:
.. literalinclude:: MyProject/myproject/templates/mytemplate.pt
:linenos:
:language: xml
-This is a :term:`z3c.pt` template. It displays the current project
-name when it is rendered. It is referenced by the ``my_view``
-function in the ``views.py`` module. Templates are accessed and used
-by view functions.
+It displays the current project name when it is rendered. It is
+referenced by the ``my_view`` function in the ``views.py`` module.
+Templates are accessed and used by view functions.
``tests.py``
~~~~~~~~~~~~
diff --git a/docs/narr/templates.rst b/docs/narr/templates.rst
index 80b530a8c..dce66ae3d 100644
--- a/docs/narr/templates.rst
+++ b/docs/narr/templates.rst
@@ -5,25 +5,35 @@ A :term:`template` is a usually file on disk which can be used to
render data provided by a :term:`view`, surrounded by more static
information.
-Templating With :term:`z3c.pt` (ZPT) Page Templates
----------------------------------------------------
+Templating With :term:`Chameleon` (:term:`chameleon.zpt`) Page Templates
+------------------------------------------------------------------------
Like Zope, :mod:`repoze.bfg` uses Zope Page Templates (:term:`ZPT`) as
-its default templating language. However, :mod:`repoze.bfg` uses a
-different implementation of the :term:`ZPT` specification than Zope
-does: the :term:`z3c.pt` templating engine. This templating engine
+its default and best-supported templating language. However,
+:mod:`repoze.bfg` uses a different implementation of the :term:`ZPT`
+specification than Zope does: the :term:`Chameleon`
+:term:`chameleon.zpt` templating engine. This templating engine
complies with the `Zope Page Template
<http://wiki.zope.org/ZPT/FrontPage>`_ template specification and is
significantly faster.
-Given that there is a :term:`z3c.pt` template named ``foo.html`` in a
-directory in your application named ``templates``, you can render the
-template from a view like so:
+.. note:: :mod:`repoze.bfg` can also allow for the use of Genshi-style
+ templates via the ``chameleon.genshi`` package, support for which
+ is built-in to :mod:`repoze.bfg`. The :mod:`repoze.bfg` API
+ functions for getting and rendering Chameleon Genshi-style
+ templates mirrors the Chameleon ZPT-style API completely; only the
+ template files themselves must differ. See :ref:`template_module`
+ for more information about using Genshi-style templates within
+ :mod:`repoze.bfg`.
+
+Given that there is a :term:`chameleon.zpt` template named
+``foo.html`` in a directory in your application named ``templates``,
+you can render the template from a view like so:
.. code-block:: python
:linenos:
- from repoze.bfg.template import render_template_to_response
+ from repoze.bfg.chameleon_zpt import render_template_to_response
def sample_view(context, request):
return render_template_to_response('templates/foo.html', foo=1, bar=2)
@@ -35,18 +45,18 @@ Relative to the directory in which the ``views.py`` file which names
it lives, which is usually the :mod:`repoze.bfg` application's
:term:`package` directory.
-``render_template_to_response`` always renders a :term:`z3c.pt`
+``render_template_to_response`` always renders a :term:`chameleon.zpt`
template, and always returns a Response object which has a *status
code* of ``200 OK`` and a *content-type* of ``text-html``. If you
need more control over the status code and content-type, use the
-``render_template`` function instead, which also renders a z3c.pt
-template but returns a string instead of a Response. You can use
-the string manually as a response body:
+``render_template`` function instead, which also renders a ZPT
+template but returns a string instead of a Response. You can use the
+string manually as a response body:
.. code-block:: python
:linenos:
- from repoze.bfg.template import render_template
+ from repoze.bfg.chameleon_zpt import render_template
from webob import Response
def sample_view(context, request):
result = render_template('templates/foo.html', foo=1, bar=2)
@@ -71,7 +81,7 @@ an XSLT as follows:
.. code-block:: python
:linenos:
- from repoze.bfg.template import render_transform_to_response
+ from repoze.bfg.xslt import render_transform_to_response
from lxml import etree
node = etree.Element("root")
return render_transform_to_response('templates/foo.xsl', node)
@@ -85,7 +95,7 @@ You can also pass XSLT parameters in as keyword arguments:
.. code-block:: python
:linenos:
- from repoze.bfg.template import render_transform_to_response
+ from repoze.bfg.xslt import render_transform_to_response
from lxml import etree
node = etree.Element("root")
value1 = "'app1'"