templates

This commit is contained in:
2016-02-22 00:34:19 -05:00
parent ca270f5833
commit 8cf1d124bb
+14 -7
View File
@@ -270,12 +270,11 @@ dynamic content to the template engine, and to the templates themselves.
Jinja2 Jinja2
------ ------
`Jinja2 <http://jinja.pocoo.org/>`_ is a template engine which is similar to `Jinja2 <http://jinja.pocoo.org/>`_ is a very well-regarded template engine.
the Django template system with some extra features. It is a text-based
template language and thus can be used to generate any markup. It allows It uses a text-based template language and can thus be used to generate any
customization of filters, tags, tests and globals, and unlike the template type markup, not just HTML. It allows customization of filters, tags, tests
system implemented in the Django Framework, also allows calling functions. and globals. It features many improvements over Django's templating system.
Jinja2 is released under the BSD license.
Here some important html tags in Jinja2: Here some important html tags in Jinja2:
@@ -297,7 +296,6 @@ Here some important html tags in Jinja2:
{% endfor %} {% endfor %}
The next listings is an example of a web site in combination with the Tornado The next listings is an example of a web site in combination with the Tornado
web server. Tornado is not very complicated to use. web server. Tornado is not very complicated to use.
@@ -385,8 +383,12 @@ into the corresponding block in the :file:`base.html` page.
</p> </p>
{% endblock %} {% endblock %}
Jinja2 is the recommended templating library for new Python web applications.
Chameleon Chameleon
--------- ---------
`Chameleon <https://chameleon.readthedocs.org/>`_ Page Templates are an HTML/XML template `Chameleon <https://chameleon.readthedocs.org/>`_ Page Templates are an HTML/XML template
engine implementation of the `Template Attribute Language (TAL) <http://en.wikipedia.org/wiki/Template_Attribute_Language>`_, engine implementation of the `Template Attribute Language (TAL) <http://en.wikipedia.org/wiki/Template_Attribute_Language>`_,
`TAL Expression Syntax (TALES) <http://chameleon.readthedocs.org/en/latest/reference.html#expressions-tales>`_, `TAL Expression Syntax (TALES) <http://chameleon.readthedocs.org/en/latest/reference.html#expressions-tales>`_,
@@ -445,8 +447,11 @@ you can replace it with a more terse and readable syntax that uses the pattern
But keep in mind that the full `<span tal:replace="expression">Default Text</span>` But keep in mind that the full `<span tal:replace="expression">Default Text</span>`
syntax also allows for default content in the unrendered template. syntax also allows for default content in the unrendered template.
Being from the Pyramid world, Chameleon is not widely used.
Mako Mako
---- ----
`Mako <http://www.makotemplates.org/>`_ is a template language that compiles to Python `Mako <http://www.makotemplates.org/>`_ is a template language that compiles to Python
for maximum performance. Its syntax and api is borrowed from the best parts of other for maximum performance. Its syntax and api is borrowed from the best parts of other
templating languages like Django and Jinja2 templates. It is the default template templating languages like Django and Jinja2 templates. It is the default template
@@ -482,6 +487,8 @@ To render a very basic template, you can do the following:
from mako.template import Template from mako.template import Template
print(Template("hello ${data}!").render(data="world")) print(Template("hello ${data}!").render(data="world"))
Mako is well respected within the Python web community.
.. rubric:: References .. rubric:: References
.. [1] `The mod_python project is now officially dead <http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html>`_ .. [1] `The mod_python project is now officially dead <http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html>`_