diff --git a/combo/utils/urls.py b/combo/utils/urls.py index 10703e9f..b0c17c43 100644 --- a/combo/utils/urls.py +++ b/combo/utils/urls.py @@ -55,7 +55,7 @@ def get_templated_url(url, context=None): except VariableDoesNotExist as e: raise TemplateError(e.msg, e.params) except TemplateSyntaxError: - raise TemplateError('syntax error') + return 'TEMPLATE ERROR' # ezt-like template def repl(matchobj): varname = matchobj.group(0)[1:-1] diff --git a/tests/test_pages.py b/tests/test_pages.py index b8f40a9f..2adfbdb7 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -296,3 +296,13 @@ def test_render(app): response = app.get(page.get_online_url()) assert '' in response.text assert 'Combo - foo' in response.text + +def test_render_cell_having_href_template_error(app): + page = Page(title=u'foo', slug='foo', template_name='standard-sidebar', order=0, description="page description") + page.save() + cell = TextCell(page=page, + text='link', + order=0, placeholder='content') + cell.save() + response = app.get(page.get_online_url()) + assert 'link' in response.text diff --git a/tests/test_utils.py b/tests/test_utils.py index 422b9a88..93836700 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -131,8 +131,7 @@ def test_templated_url(): assert get_templated_url('{{ foo.0.bar }}{{ foo.0.zoo }}', context={'foo': [{'bar': 'ok'}, 'ko']}) == 'ok' # catch django syntax errors in TemplateError for template in ('{% foobar %}', '{% if "coucou" %}', '{{}}', '{{ if "x" }}', '{{ _private }}'): - with pytest.raises(TemplateError, match='syntax error'): - assert get_templated_url(template, context=ctx) == 'bar' + assert get_templated_url(template, context=ctx) == 'TEMPLATE ERROR' # requestcontext with override_settings(TEMPLATE_VARS={'test_url': 'http://www.example.net'}):