summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLars Kollstedt <lk@man-da.de>2020-03-10 12:26:44 +0100
committerDavid Lord <davidism@gmail.com>2021-04-05 09:50:45 -0700
commit8016b5f139473675ace9a5a1eb845298335e9dd2 (patch)
treee6647b3929df3a376aec6546fb15cee486742205 /tests
parent7bea9193f48b6f8fac147ace7ca349a05e594af4 (diff)
downloadjinja2-8016b5f139473675ace9a5a1eb845298335e9dd2.tar.gz
filters.py: do_indent: ident filter can indent with arbitrary characters
Allow indention with generic characters, e.g. Tabs. Implemenented the behavior requested in https://github.com/pallets/jinja/pull/1167#issuecomment-612644701 The width param can be string or int, if it is string it's the raw indention e.g. "\t". If it's int it's the number of spaces. In other cases an FilterArgumentError is raised, to avoid confusion.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_filters.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test_filters.py b/tests/test_filters.py
index 5a11d3f..2c119c3 100644
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -185,6 +185,10 @@ class TestFilter:
"""
self._test_indent_multiline_template(env, markup=True)
+ def test_indent_width_string(self, env):
+ t = env.from_string("{{ 'jinja\nflask'|indent(width='>>> ', first=True) }}")
+ assert t.render() == ">>> jinja\n>>> flask"
+
@pytest.mark.parametrize(
("value", "expect"),
(