Skip to content
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

Add possibility to customize footnote reference markup #27

Closed
wants to merge 1 commit into from

Conversation

an-ant0ni0
Copy link

We needed the possibility to change the template for rendering the footnote reference.

Maybe this is useful for others?

@nickmoreton nickmoreton added the enhancement New feature or request label Oct 17, 2022
willbarton added a commit to cfpb/wagtail-footnotes that referenced this pull request Jul 3, 2024
This change does two things to permit custom rendering of footnote references in the `RichTextBlockWithFootnotes` block:

1. Moves reference rendering from an inner function in the `replace_footnote_tags()` method to a separate `render_footnote_tag()` method on the `RichTextBlockWithFootnotes` block class. This provides an easy extension point for subclasses of `RichTextBlockWithFootnotes` to customize rendering that doesn't require duplication of a lot of other code.
2. The default implementation of `render_footnote_tag` renders using a Django template, optionally set with the `WAGTAIL_FOOTNOTES_REFERENCE_TEMPLATE` setting, allowing users to override rendering by providing a different template to that setting.

This is similar in spirit to @an-ant0ni0's proposal in torchbox#27, however we've chosen to move rendering out of Python f-strings altogether and into Django (or any other configured engine's) templates.
@zerolab
Copy link
Member

zerolab commented Jul 3, 2024

Closing in favour of #70.
Thank you for this @an-ant0ni0. It wasnt quite the right approach, and am sorry it went under the radar/without feedback for so long

@zerolab zerolab closed this Jul 3, 2024
willbarton added a commit to cfpb/wagtail-footnotes that referenced this pull request Jul 3, 2024
This change does two things to permit custom rendering of footnote references in the `RichTextBlockWithFootnotes` block:

1. Moves reference rendering from an inner function in the `replace_footnote_tags()` method to a separate `render_footnote_tag()` method on the `RichTextBlockWithFootnotes` block class. This provides an easy extension point for subclasses of `RichTextBlockWithFootnotes` to customize rendering that doesn't require duplication of a lot of other code.
2. The default implementation of `render_footnote_tag` renders using a Django template, optionally set with the `WAGTAIL_FOOTNOTES_REFERENCE_TEMPLATE` setting, allowing users to override rendering by providing a different template to that setting.

This is similar in spirit to @an-ant0ni0's proposal in torchbox#27, however we've chosen to move rendering out of Python f-strings altogether and into Django (or any other configured engine's) templates.
zerolab pushed a commit that referenced this pull request Aug 13, 2024
* Allow custom footnote reference rendering

This change does two things to permit custom rendering of footnote references in the `RichTextBlockWithFootnotes` block:

1. Moves reference rendering from an inner function in the `replace_footnote_tags()` method to a separate `render_footnote_tag()` method on the `RichTextBlockWithFootnotes` block class. This provides an easy extension point for subclasses of `RichTextBlockWithFootnotes` to customize rendering that doesn't require duplication of a lot of other code.
2. The default implementation of `render_footnote_tag` renders using a Django template, optionally set with the `WAGTAIL_FOOTNOTES_REFERENCE_TEMPLATE` setting, allowing users to override rendering by providing a different template to that setting.

This is similar in spirit to @an-ant0ni0's proposal in #27, however we've chosen to move rendering out of Python f-strings altogether and into Django (or any other configured engine's) templates.
nickmoreton pushed a commit to torchbox-forks/wagtail-footnotes that referenced this pull request Aug 20, 2024
* Allow custom footnote reference rendering

This change does two things to permit custom rendering of footnote references in the `RichTextBlockWithFootnotes` block:

1. Moves reference rendering from an inner function in the `replace_footnote_tags()` method to a separate `render_footnote_tag()` method on the `RichTextBlockWithFootnotes` block class. This provides an easy extension point for subclasses of `RichTextBlockWithFootnotes` to customize rendering that doesn't require duplication of a lot of other code.
2. The default implementation of `render_footnote_tag` renders using a Django template, optionally set with the `WAGTAIL_FOOTNOTES_REFERENCE_TEMPLATE` setting, allowing users to override rendering by providing a different template to that setting.

This is similar in spirit to @an-ant0ni0's proposal in torchbox#27, however we've chosen to move rendering out of Python f-strings altogether and into Django (or any other configured engine's) templates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants