Skip to content

Conversation

@hrdixon
Copy link
Contributor

@hrdixon hrdixon commented Nov 19, 2024

Fixing bug: LStrip and Trim are not being applied consistently with other jinja engines when it comes to comment blocks.

Example python behaviour (Jinja2):

Python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from jinja2 import Environment
>>> env = Environment(trim_blocks=True, lstrip_blocks=True)
>>> template = env.from_string("""<div>
...     {# a comment #}
...         yay
...     {# another comment
...        This time, over multiple lines
...      #}
...         whoop
... </div>""")
>>> template.render()
'<div>\n        yay\n        whoop\n</div>'
>>> print(template.render())
<div>
        yay
        whoop
</div>
>>>

Copy link
Contributor

@jasmith-hs jasmith-hs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@hrdixon hrdixon changed the title Apply whitespace rules for LStrip and Trim to comment blocks Apply whitespace rules for LStrip and Trim to comment blocks, resolves #1218 Nov 27, 2024
@jasmith-hs jasmith-hs merged commit 703b11c into HubSpot:master Dec 3, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants