diff --git a/docs/templates.txt b/docs/templates.txt index 41b15f3d19..eab4b129ce 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -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_ 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/ .. _Smarty: http://smarty.php.net/ .. _CheetahTemplate: http://www.cheetahtemplate.org/ +.. _your own extensions: ../templates_python/#extending-the-template-system Templates ========= @@ -382,7 +399,7 @@ loop:: ... {% endfor %} - + Outside of a loop, give the values a unique name the first time you call it, then use that name each successive time through:: @@ -390,16 +407,16 @@ then use that name each successive time through::