SvartalF
SvartalF

Reputation: 163

How to get django context automatically in Jinja2 filters?

For example, I have an paginator object with a lot of attributes, and don't want do write something like {{ paginate(paginator) }} in templates.

How can a get context automatically in the filter function, like a django register.inclusion_tag(…, takes_context=True)?

Yes, of course, I can do something like paginate(paginator), but it looks weird, imho.

Upvotes: 0

Views: 534

Answers (1)

SvartalF
SvartalF

Reputation: 163

Oh, here it is.

@jinja2.contextfunction
def paginate(context):
    pass

Upvotes: 1

Related Questions