diff options
author | Lars Kollstedt <lk@man-da.de> | 2020-03-10 12:26:44 +0100 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2021-04-05 09:50:45 -0700 |
commit | 8016b5f139473675ace9a5a1eb845298335e9dd2 (patch) | |
tree | e6647b3929df3a376aec6546fb15cee486742205 /tests | |
parent | 7bea9193f48b6f8fac147ace7ca349a05e594af4 (diff) | |
download | jinja2-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.py | 4 |
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"), ( |