Documentation improvement, write a section about nested template extends.#1011
Closed
scrosby wants to merge 1 commit intopallets:2.10.xfrom
Closed
Documentation improvement, write a section about nested template extends.#1011scrosby wants to merge 1 commit intopallets:2.10.xfrom
scrosby wants to merge 1 commit intopallets:2.10.xfrom
Conversation
jab
suggested changes
Jun 6, 2019
| Nesting template extends. | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| In the case of multiple levels of %extends, the childmost {% block %} substitutes into the parent template. For instance, |
Contributor
There was a problem hiding this comment.
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:: |
Contributor
There was a problem hiding this comment.
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
superreferences the motivation behind this PR / shouldn't it be mentioned here?
|
|
||
| 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. |
Contributor
There was a problem hiding this comment.
The single backticks have no effect, rst uses double-backticks.
| {% 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. |
Contributor
There was a problem hiding this comment.
- double-backticks
- "Rendering
a2.tmplwill outputFrom A1: Want-this-to-be-skipped." I find this confusing because renderinga2.tmplwill 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.
|
|
||
| #a4.tmpl | ||
| {% extends "a2.tmpl" %} | ||
| {% block body %} From A4: {{super.super()}} {% endblock %} |
Contributor
There was a problem hiding this comment.
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.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #928