Repository navigation
Fix/22 footnotes not replaced in structblocks - #95
Draft
kevinhowbrook wants to merge 7 commits into
Draft
kevinhowbrook wants to merge 7 commits into
kevinhowbrook wants to merge 7 commits into
Conversation
Two StructBlocks with a RichTextBlockWithFootnotes caption, each using one
of the common template patterns for rendering a child rich text value:
{{ value.caption|richtext }} and {% include_block value.caption %}.
These are used by the tests for footnotes inside StructBlocks.
When a RichTextBlockWithFootnotes is a StructBlock child and the struct's
template renders it with {% include_block value.caption %}, the footnote
tags are output as raw <footnote> markup and the footnotes aren't added to
the page's footnotes list. These tests fail until that's fixed:
- the caption's footnote tag is replaced with a numbered link
- the footnote is added to page.footnotes_list
- a full page request renders and lists the footnote
Two regression guards pass already and must keep passing: the
{% include_block value.bound_blocks.caption %} workaround, and
{{ value.caption|richtext }} rendering without raising.
{% include_block %} only renders a value through its block if the value
has a render_as_block() method. RichTextBlockWithFootnotes returned plain
RichText values, so a StructBlock template using
{% include_block value.caption %} skipped the block's render() and the
footnote tags were never replaced.
Values loaded from the database are now RichTextWithFootnotes, a RichText
subclass that keeps a reference to its block and implements
render_as_block(). Because it's still a RichText, the |richtext filter and
anything reading value.source (saving, search, the API) are unchanged.
RichTextBlock creates RichText values in two more places besides
to_python(): value_from_form(), used for page previews built from
submitted form data, and normalize(), used when values are set from
Python. Values created on those paths are still plain RichText, so
{% include_block value.caption %} doesn't replace their footnotes yet.
Without these, footnotes in a StructBlock were replaced on published pages but not in page previews (which build values from form data) or for values set from Python.
Explain that StructBlock templates should render RichTextBlockWithFootnotes
children with {% include_block %}, and that the |richtext filter (and a
StructBlock without a template) can't replace footnotes because they don't
have access to the page.
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a very raw WIP for #22
Fix footnotes not being replaced inside StructBlocks
When a RichTextBlockWithFootnotes was a StructBlock child, rendering it with {% include_block value.caption %} output raw markup and left the footnote out of the footnotes list. (The |richtext filter still can't replace footnotes, the README is updated to adisve people to use {% include_block %} in StructBlock templates instead.