Skip to content

keep_trailing_newline and other options missing from Environment.overlay #1645

@Tom-Brouwer

Description

@Tom-Brouwer

I was planning to use the Environment.overlay method in a flask app, to create a new environment with specific environment options that only apply to one endpoint.

However, it seems like some options were not added to the overlay method, when the options were added to jinja (example pull request). In my case this is the 'keep_trailing_newline' option, but also the 'newline_sequence', 'enable_async' options are not available on the overlay method.

Replication

# Note that this is inside a Flask Blueprint
from flask import current_app
jinja_env = current_app.jinja_env.overlay(keep_trailing_newline=True)
# This command gives the error:
# TypeError: Environment.overlay() got an unexpected keyword argument 'keep_trailing_newline'

Expectation

I would have expected to be able to change at least the 'newline_sequence' and 'keep_trailing_newline' options via the overlay method.

Environment

  • Python version: 3.10.2
  • Jinja version: 3.1.0
click==8.0.4
fastjsonschema==2.15.3
Flask==2.0.3
itsdangerous==2.1.2
Jinja2==3.1.0
MarkupSafe==2.1.1
PyYAML==6.0
Werkzeug==2.0.3

Note: If required I can submit a pull-request to add all 3 options to the overlay function, please let me know!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions