From: Fabien Potencier Date: Sat, 18 Feb 2012 09:05:10 +0000 (+0100) Subject: clarified documentation (closes #602) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=a61d42084caeadc4cc8c3bd1caded87631c12636;p=konrad%2Ftwig.git clarified documentation (closes #602) --- diff --git a/doc/tags/extends.rst b/doc/tags/extends.rst index 0865bf8..8d64436 100644 --- a/doc/tags/extends.rst +++ b/doc/tags/extends.rst @@ -32,10 +32,9 @@ skeleton document: -In this example, the :doc:`{% block %}` tags define four blocks -that child templates can fill in. All the ``block`` tag does is to tell the -template engine that a child template may override those portions of the -template. +In this example, the :doc:`block` tags define four blocks that child +templates can fill in. All the ``block`` tag does is to tell the template +engine that a child template may override those portions of the template. Child Template -------------- @@ -60,20 +59,20 @@ A child template might look like this:

{% endblock %} -The ``{% extends %}`` tag is the key here. It tells the template engine that -this template "extends" another template. When the template system evaluates -this template, first it locates the parent. The extends tag should be the -first tag in the template. +The ``extends`` tag is the key here. It tells the template engine that this +template "extends" another template. When the template system evaluates this +template, first it locates the parent. The extends tag should be the first tag +in the template. Note that since the child template doesn't define the ``footer`` block, the value from the parent template is used instead. -You can't define multiple ``{% block %}`` tags with the same name in the same +You can't define multiple ``block`` tags with the same name in the same template. This limitation exists because a block tag works in "both" directions. That is, a block tag doesn't just provide a hole to fill - it also defines the content that fills the hole in the *parent*. If there were two -similarly-named ``{% block %}`` tags in a template, that template's parent -wouldn't know which one of the blocks' content to use. +similarly-named ``block`` tags in a template, that template's parent wouldn't +know which one of the blocks' content to use. If you want to print a block multiple times you can however use the ``block`` function: diff --git a/doc/templates.rst b/doc/templates.rst index 0835718..bcd0ead 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -292,8 +292,8 @@ skeleton document that you might use for a simple two-column page: -In this example, the :doc:`{% block %}` tags define four blocks -that child templates can fill in. All the ``block`` tag does is to tell the +In this example, the :doc:`block` tags define four blocks that +child templates can fill in. All the ``block`` tag does is to tell the template engine that a child template may override those portions of the template. @@ -317,10 +317,10 @@ A child template might look like this:

{% endblock %} -The :doc:`{% extends %}` tag is the key here. It tells the -template engine that this template "extends" another template. When the -template system evaluates this template, first it locates the parent. The -extends tag should be the first tag in the template. +The :doc:`extends` tag is the key here. It tells the template +engine that this template "extends" another template. When the template system +evaluates this template, first it locates the parent. The extends tag should +be the first tag in the template. Note that since the child template doesn't define the ``footer`` block, the value from the parent template is used instead.