Skip to content

BUG: Styler subclassing and from_custom_template no longer working #42053

Closed
@attack68

Description

@attack68

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO HTMLread_html, to_html, Styler.apply, Styler.applymapRegressionFunctionality that used to work in a prior pandas versionStylerconditional formatting using DataFrame.style

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions