Skip to content

Documentation improvement, write a section about nested template extends.#1011

Closed
scrosby wants to merge 1 commit intopallets:2.10.xfrom
scrosby:fix-928
Closed

Documentation improvement, write a section about nested template extends.#1011
scrosby wants to merge 1 commit intopallets:2.10.xfrom
scrosby:fix-928

Conversation

@scrosby
Copy link
Copy Markdown

@scrosby scrosby commented May 31, 2019

Fixes #928

@jab jab self-assigned this Jun 6, 2019
Comment thread docs/templates.rst
Nesting template extends.
~~~~~~~~~~~~~~~~~~~~~~~~~

In the case of multiple levels of %extends, the childmost {% block %} substitutes into the parent template. For instance,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the case of multiple levels of %extends, the childmost {% block %} substitutes into the parent template. For instance,
In the case of multiple levels of ``{% extends %}``,
``super`` references may be chained (as in ``super.super``)
to walk up the inheritance tree.
For example::

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the childmost {% block %} substitutes into the parent template

  • missing double-backticks around {% blocks %}
  • I find the reference to "parent template" potentially unclear when there is a 3-level tree. Whose parent? If the childmost template's, s/the/its would clarify.
  • Isn't the chainability of super references the motivation behind this PR / shouldn't it be mentioned here?

Comment thread docs/templates.rst

Rendering `a2.tmpl` will output `From A1: Want-this-to-be-skipped`. The text `Want-this-to-be-included.` is rendered because the `super()` call render as the text from the parent template into the block, which will then be substitute into topmost template.

Rendering `a3.tmpl` will output `From A1: Some Text`. We substitute the block text into the parent template.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single backticks have no effect, rst uses double-backticks.

Comment thread docs/templates.rst
{% block body %} From A4: {{super.super()}} {% endblock %}


Rendering `a2.tmpl` will output `From A1: Want-this-to-be-skipped`. The text `Want-this-to-be-included.` is rendered because the `super()` call render as the text from the parent template into the block, which will then be substitute into topmost template.
Copy link
Copy Markdown
Contributor

@jab jab Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • double-backticks
  • "Rendering a2.tmpl will output From A1: Want-this-to-be-skipped." I find this confusing because rendering a2.tmpl will actually output "From A1: Want-this-to-be-skipped. Want-this-to-be-included.". It shouldn't be broken into the next sentence.
  • s/substitute/substituted
  • s/topmost/the topmost
  • All the other lines in these docs wrap at 78 characters.

Comment thread docs/templates.rst

#a4.tmpl
{% extends "a2.tmpl" %}
{% block body %} From A4: {{super.super()}} {% endblock %}
Copy link
Copy Markdown
Contributor

@jab jab Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add whitespace inside the {{super.super()}} to match the rest of these docs.

This example is a great start. I wonder if it can be made any more minimal in such a way that it increases clarity.

@jab
Copy link
Copy Markdown
Contributor

jab commented Jun 6, 2019

@scrosby I merged your commit from this PR (b5c6c9c) into master in #1015 (after making the touchups discussed above, since it sounded like you'd be too busy to do another round of changes). Thanks for the PR!

@jab jab closed this Jun 6, 2019
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants