Added a section to the template documentation to clarify the arbitrary Python

code should not be expected to work. The might help balance expectations.
Thanks, James Bennett. Fixed #5125.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6562 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-10-20 11:05:15 +00:00
parent c858efe912
commit 22ee68961a
1 changed files with 27 additions and 10 deletions

View File

@ -11,9 +11,26 @@ ease. It's designed to feel comfortable to those used to working with HTML. If
you have any exposure to other text-based template languages, such as Smarty_ you have any exposure to other text-based template languages, such as Smarty_
or CheetahTemplate_, you should feel right at home with Django's templates. or CheetahTemplate_, you should feel right at home with Django's templates.
.. admonition:: Philosophy
If you have a background in programming, or if you're used to languages
like PHP which mix programming code directly into HTML, you'll want to
bear in mind that the Django template system is not simply Python embedded
into HTML. This is by design: the template system is meant to express
presentation, not program logic.
The Django template system provides tags which function similarly to some
programming constructs -- an ``{% if %}`` tag for boolean tests, a ``{%
for %}`` tag for looping, etc. -- but these are not simply executed as the
corresponding Python code, and the template system will not execute
arbitrary Python expressions. Only the tags, filters and syntax listed
below are supported by default (although you can add `your own
extensions`_ to the template language as needed).
.. _`The Django template language: For Python programmers`: ../templates_python/ .. _`The Django template language: For Python programmers`: ../templates_python/
.. _Smarty: http://smarty.php.net/ .. _Smarty: http://smarty.php.net/
.. _CheetahTemplate: http://www.cheetahtemplate.org/ .. _CheetahTemplate: http://www.cheetahtemplate.org/
.. _your own extensions: ../templates_python/#extending-the-template-system
Templates Templates
========= =========