parent.rst 563B

123456789101112131415161718192021
  1. ``parent``
  2. ==========
  3. When a template uses inheritance, it's possible to render the contents of the
  4. parent block when overriding a block by using the ``parent`` function:
  5. .. code-block:: jinja
  6. {% extends "base.html" %}
  7. {% block sidebar %}
  8. <h3>Table Of Contents</h3>
  9. ...
  10. {{ parent() }}
  11. {% endblock %}
  12. The ``parent()`` call will return the content of the ``sidebar`` block as
  13. defined in the ``base.html`` template.
  14. .. seealso:: :doc:`extends<../tags/extends>`, :doc:`block<../functions/block>`, :doc:`block<../tags/block>`