Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 3f91814

Browse files
authored
Jinja2 3.1 support (#104)
1 parent f594d20 commit 3f91814

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

exhibition/filters/jinja2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from datetime import datetime, timezone
3333

34-
from jinja2 import Environment, FileSystemLoader, contextfilter
34+
from jinja2 import Environment, FileSystemLoader, pass_context
3535
from jinja2.exceptions import TemplateRuntimeError
3636
from jinja2.ext import Extension
3737
from jinja2.nodes import CallBlock, Const, ContextReference
@@ -78,7 +78,7 @@ def metareject(nodes, key):
7878
yield n
7979

8080

81-
@contextfilter
81+
@pass_context
8282
def markdown(ctx, text):
8383
kwargs = DEFAULT_MD_KWARGS.copy()
8484
node = ctx[NODE_TMPL_VAR]
@@ -88,7 +88,7 @@ def markdown(ctx, text):
8888
return md_func(text, **kwargs)
8989

9090

91-
@contextfilter
91+
@pass_context
9292
def pandoc(ctx, text, fmt=None):
9393
"""Use Pandoc to convert from one format to another. Takes source format as
9494
an optional argument.

exhibition/tests/test_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import base64
2525
import pathlib
2626

27-
from jinja2 import Markup
2827
from jinja2.exceptions import TemplateRuntimeError
28+
from markupsafe import Markup
2929

3030
from exhibition.filters.base import content_filter as base_filter
3131
from exhibition.filters.external import content_filter as external_filter

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
python_requires=">=3.8",
3838
install_requires=[
3939
"click",
40-
"jinja2<3.1",
40+
"jinja2>=3.0,<3.1",
4141
"markdown",
4242
"ruamel.yaml",
4343
"typogrify",

tox.ini

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ envlist =
44
flake8
55
isort
66
docs
7-
py{38,39,310,311,312}-jinja{211,210,300}
7+
py{38,39,310,311,312}-jinja{300,310}
88
coverage
99

1010
[flake8]
@@ -32,16 +32,13 @@ python =
3232
3.8: clean,py38,coverage
3333
3.9: clean,py39,coverage
3434
3.10: clean,py310,coverage
35-
3.11: clean,py310,coverage
36-
3.12: clean,py310,coverage
35+
3.11: clean,py311,coverage
36+
3.12: clean,py312,coverage
3737

3838
[testenv]
3939
deps =
40+
jinja310: jinja2>=3.1,<3.2
4041
jinja300: jinja2>=3.0,<3.1
41-
jinja211: jinja2>=2.11,<2.12
42-
MarkupSafe<2.1
43-
jinja210: jinja2>=2.10,<2.11
44-
MarkupSafe<2.1
4542
coverage
4643
commands = coverage run -a --branch -m unittest {posargs}
4744

0 commit comments

Comments
 (0)