BUG: Styler subclassing and from_custom_template no longer working · Issue #42053 · pandas-dev/pandas (original) (raw)

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.