Skip to content

prepare_jinja2_environment() hook should take datasette argument #1809

@simonw

Description

@simonw

That plugin hook's current signature is:

@hookspec
def prepare_jinja2_environment(env):
"""Modify Jinja2 template environment e.g. register custom template tags"""

As a result in the first alpha release of datasette-edit-templates I had to include this horrific hack: https://github.com/simonw/datasette-edit-templates/blob/087f6a6cabc20020f2b0524f11aa3a7836320848/datasette_edit_templates/__init__.py#L72-L75

@hookimpl
def prepare_jinja2_environment(env):
    # TODO: This should ideally take datasette, but that's not an argument yet
    datasette = inspect.currentframe().f_back.f_back.f_back.f_back.f_locals["self"]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions