Skip to content

Commit

Permalink
Fix jinja2 support in Python 3
Browse files Browse the repository at this point in the history
Closes #294
  • Loading branch information
Suor committed Aug 19, 2018
1 parent 2a494cd commit 47f6d29
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cacheops/jinja2.py
Expand Up @@ -19,7 +19,7 @@ def parse(self, parser):
tag_name = parser.stream.current.value
tag_location = '%s:%s' % (parser.name, lineno)

parser.stream.next()
next(parser.stream)
args, kwargs = self.parse_args(parser)
args = [nodes.Const(tag_name), nodes.Const(tag_location)] + args

Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Expand Up @@ -3,3 +3,4 @@ redis>=2.9.1
funcy>=1.8,<2.0
six>=1.4.0
before_after==1.0.0
jinja2>=2.10
6 changes: 6 additions & 0 deletions tests/tests.py
Expand Up @@ -428,6 +428,12 @@ def my_cached(context):
self.assertRendersTo(t, {'inc': inc, 'flag': True}, '.1.1')
self.assertRendersTo(t, {'inc': inc, 'flag': False}, '.2.3')

def test_jinja2(self):
from jinja2 import Environment
env = Environment(extensions=['cacheops.jinja2.cache'])
t = env.from_string('Hello, {% cached %}{{ name }}{% endcached %}')
t.render(name='Alex')


class IssueTests(BaseTestCase):
fixtures = ['basic']
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -37,6 +37,7 @@ deps =
gdal=={env:GDAL_VERSION:2.1}
pypy: psycopg2cffi>=2.7.6
before_after==1.0.0
jinja2>=2.10
commands =
./run_tests.py []
env CACHEOPS_PREFIX=1 ./run_tests.py []
Expand Down

0 comments on commit 47f6d29

Please sign in to comment.