Skip to content

LStrip and Trim don't apply to comment tags, but they should #1218

Closed

Description

@hrdixon

LStrip and Trim apply correctly for {% ... %} tags, but don't work for {# ... #} tags.
In Jinja2 (python), the two work the same:

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>

I've created a PR to fix this.

Activity

  1. changed the title [-]LStrip and Trim don't apply to comment tags, but they should[/-] [+]LStrip and Trim don't apply to comment tags, but they should, resolves #1218[/+] on Nov 20, 2024
  2. changed the title [-]LStrip and Trim don't apply to comment tags, but they should, resolves #1218[/-] [+]LStrip and Trim don't apply to comment tags, but they should[/+] on Nov 27, 2024
  3. added a commit that references this issue on Dec 6, 2024
    703b11c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions