From 620da47e7fc36c52005dd8b125c4fa4619a74544 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 23 Sep 2011 07:36:42 +0200 Subject: [PATCH] tweaked docs --- doc/templates.rst | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/doc/templates.rst b/doc/templates.rst index 90ca31b..321d8a3 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -1628,6 +1628,9 @@ is ignored. To avoid name conflicts, you can rename imported blocks: {% block title %}{% endblock %} {% block content %}{% endblock %} +.. versionadded:: 1.3 + The ``parent()`` support was added in Twig 1.3. + The ``parent()`` function automatically determines the correct inheritance tree, so it can be used when overriding a block defined in an imported template: @@ -1648,6 +1651,21 @@ template: In this example, ``parent()`` will correctly call the ``sidebar`` block from the ``blocks.html`` template. +.. tip:: + + In Twig 1.2, renaming allows you to simulate inheritance by calling the + "parent" block: + + .. code-block:: jinja + + {% extends "base.html" %} + + {% use "blocks.html" with sidebar as parent_sidebar %} + + {% block sidebar %} + {{ block('parent_sidebar') }} + {% endblock %} + .. note:: You can use as many ``use`` statements as you want in any given template. -- 1.7.2.5