Skip to content

BUG: Styler subclassing and from_custom_template no longer working #42053

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

Closed
attack68 opened this issue Jun 16, 2021 · 0 comments · Fixed by #42091
Closed

BUG: Styler subclassing and from_custom_template no longer working #42053

attack68 opened this issue Jun 16, 2021 · 0 comments · Fixed by #42091
Labels
Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Regression Functionality that used to work in a prior pandas version Styler conditional formatting using DataFrame.style
Milestone

Comments

@attack68
Copy link
Contributor

attack68 commented Jun 16, 2021

PR #40312 introduced jinja2 template inheritance for the styler HTML parsing.

Essentially we went from a structure like:

# main.template
{% block foobar %}
<html>
{% endblock %}

to

# main.template
{% include "sub.template" %}

# sub.template
{% block foobar %}
<html>
{% endblock %}

The problem with that is that Styler offers (and documents) the ability to subclass it and extend the main template so that defined blocks can be overwritten.

In jinja2 the included blocks of an extended template cannot be overwritten.

Hence a patch is to point the docs to extending the sub templates instead, and amending the from_custom_template method to amend each sub template instead of the main.

This fixes all functionality but is not backwards compatible becuase of the arg change.

@attack68 attack68 added Bug Regression Functionality that used to work in a prior pandas version IO HTML read_html, to_html, Styler.apply, Styler.applymap Styler conditional formatting using DataFrame.style labels Jun 16, 2021
@simonjayhawkins simonjayhawkins added this to the 1.3 milestone Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Regression Functionality that used to work in a prior pandas version Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants