ydata-profiling icon indicating copy to clipboard operation
ydata-profiling copied to clipboard

Feature Request - Override templates of the html flavour

Open prhbrt opened this issue 2 years ago • 1 comments

Missing functionality

Override templates of the html flavour.

Proposed feature

Allow overriding (some) templates in src/pandas_profiling/report/presentation/flavours/html/templates/ to personalize pdp.

Alternatives considered

I monkey patched pdp to support overriding templates, e.g. to change the layout a bit as jinja2 supports this, but this isn't a clean way to do it.

from pandas_profiling.report.presentation.flavours.html import templates
from pandas_profiling.report.formatters import fmt, fmt_badge, fmt_numeric, fmt_percent
import jinja2
from jinja2 import ChoiceLoader, FileSystemLoader

templates.package_loader = ChoiceLoader([
    FileSystemLoader(some_path),
    templates.package_loader,
])

templates.jinja2_env = jinja2.Environment(
    lstrip_blocks=True, trim_blocks=True, loader=templates.package_loader
)
templates.jinja2_env.filters["is_list"] = lambda x: isinstance(x, list)
templates.jinja2_env.filters["fmt_badge"] = fmt_badge
templates.jinja2_env.filters["fmt_percent"] = fmt_percent
templates.jinja2_env.filters["fmt_numeric"] = fmt_numeric
templates.jinja2_env.filters["fmt"] = fmt

Additional context

No response

prhbrt avatar Jan 04 '23 10:01 prhbrt

I concur this. I am looking for a way to replace the title with a dropdown box to list all reports, or adding a dedicated menu item for this. Overriding report/presenation/flavours/html//templates/wrapper/nagivation.html would be the cleanest way to do it.

BoPeng avatar Oct 28 '23 18:10 BoPeng