-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Footnotes are not replaced when RichTextWithFootnotesBlock is a StructBlock sub-block #22
Comments
I just realised that there is a simpler way to get
With this, |
Interesting, I do think that it'd be great if we could standardise the Personally, after an initial skim of your suggestion, I quite like the idea of creating a |
One downside of this approach is that |
I was bitten by this the other day.
Agreed. I'm not sure if I had read that specific section of the docs before but if I did, I completely forgot about it. I eventually stumbled upon them and was able to solve my issue by using |
When you include a
RichTextWithFootnotesBlock
in aStreamBlock
definition, things work great! This is becauseStreamBlock.to_python
returns aStreamValue
, which has arender_as_block()
method that feeds back intoStreamBlock.render_basic()
to do the actual rendering... which calls the render() method of each sub-block, ultimately leading toRichTextWithFootnotesBlock.replace_footnote_tags()
doing its thing.When you include a
RichTextWithFootnotesBlock
as a sub-block of aStructBlock
, things work out a little differently. The tendency is to do the following inStructBlock
templates:This definitely won't trigger
RichTextWithFootnotesBlock.replace_footnote_tags()
, because we're basically just taking the value from the block and rendering it directly.I thought that changing all instances of the above would resolve the problem:
However, that didn't do the job because
{% include_block %}
only does anything special with the value if it has arender_as_block()
method (likeStreamValue
does). If not, the value itself is used as the output value, which isn't really what we want.What we want is for
RichTextWithFootnotesBlock.render()
to always be used in rendering, and in order to do that,RichTextWithFootnotesBlock
needs to return something other than an instance ofRichText
... we need something with arender_as_block()
method (likeStreamValue
does), so that we can always bring things back toRichTextWithFootnotesBlock.render()
. Something like this worked in a project I am currently working on:With these changes, as long as I use
{% include_block %}
in all StructBlock templates, the footnotes are replaced successfully, wherever they are used:The text was updated successfully, but these errors were encountered: