-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
The lstrip_blocks doesn’t work as documented and seems to have no effect at all. I need it to help me attain more readable code and templates while keeping full control on rendered text.
Here is a fully functional sample code:
import textwrap
import jinja2
data=[
dict(a=1,b=2),
dict(a=3,b=4),
]
template = jinja2.Template(
textwrap.dedent("""\
Preamble
{% for item in data %}
Block start
This is a:{{ item.a }}
This is b:{{ item.b }}
Block end
{% endfor %}
Epilogue
"""),
lstrip_blocks=True
)
print(template.render(dict(data=data)))
Actual result:
Preamble
Block start
This is a:1
This is b:2
Block end
Block start
This is a:3
This is b:4
Block end
Epilogue
Expected and desired result:
Preamble
Block start
This is a:1
This is b:2
Block end
Block start
This is a:3
This is b:4
Block end
Epilogue
Environment:
- Python version: 3.12.8 on Fedora Linux
- Jinja version: 3.1.5
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels