Skip to content

Commit

Permalink
Fix #52
Browse files Browse the repository at this point in the history
  • Loading branch information
kblomqvist committed Jul 17, 2018
1 parent af443e9 commit 2128156
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Major release, unreleased
it default. The old behaviour can be achieved with the new option
`--remove-trailing-newline`.
- Fixed an exit code in case of undefined variable from 0 to 1.
- Fixed a bug that caused extension classes not to load.

Version 4.3
-----------
Expand Down
14 changes: 14 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,17 @@ def test_template_syntax_for_latex(tmpdir):

out = check_output(('yasha', '-e', str(ext), '-o-', str(tpl)))
assert out.decode() == expected_output


def test_extensions_file_with_do(tmpdir):
"""gh-52"""
tmpdir.chdir()

extensions = tmpdir.join('extensions.py')
extensions.write('from jinja2.ext import do')

tmpl = tmpdir.join('template.j2')
tmpl.write(r'{% set list = [1, 2, 3] %}{% do list.append(4) %}{{ list }}')

out = check_output(('yasha', '-e', str(extensions), '-o-', str(tmpl)))
assert out == b'[1, 2, 3, 4]'
5 changes: 5 additions & 0 deletions yasha/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def load_extensions(file):
except AttributeError:
PARSERS.update(parsers)

try:
CLASSES.extend(module.CLASSES)
except AttributeError:
CLASSES.extend(classes)


@click.command(context_settings=dict(
help_option_names=["-h", "--help"],
Expand Down

0 comments on commit 2128156

Please sign in to comment.