Skip to content

[BUG] [Formatter] trailing whitespace in jinja macro #1428

@jayvdb

Description

@jayvdb

System Info

  • OS: Ubuntu 24.04
  • Python Version (python --version): 3.12
  • djLint Version (djlint --version): 1.36.4
  • template language: jinja

Issue

I have a file strings.jinja as below.

djlint wants to add a trailing whitespace after | replace('\\', '\\\\')

{%- macro fix_user_string(value) -%}
    {{ value
    | replace('\\', '\\\\') 
    | replace("\n", "\\n")
    | replace("\r", "\\r")
    | replace("\"", "\\\"")
    | replace("\t", "\\t")
    | replace("\x00", "")
    | replace("\x01", "")
    | replace("\x02", "")
    | replace("\x03", "")
    | replace("\x04", "")
    | replace("\x05", "")
    | replace("\x06", "")
    | replace("\x07", "")
    | replace("\x08", "")
    | replace("\x0b", "")
    | replace("\x0c", "")
    | replace("\x0e", "")
    | replace("\x0f", "")
    | replace("\x10", "")
    | replace("\x11", "")
    | replace("\x12", "")
    | replace("\x13", "")
    | replace("\x14", "")
    | replace("\x15", "")
    | replace("\x16", "")
    | replace("\x17", "")
    | replace("\x18", "")
    | replace("\x19", "")
    | replace("\x1a", "")
    | replace("\x1b", "")
    | replace("\x1c", "")
    | replace("\x1d", "")
    | replace("\x1e", "")
    | replace("\x1f", "")
    }}
{%- endmacro -%}

How To Reproduce

Run djlint formatter on the above file. I am using the pre-commit hook djlint-reformat-jinja

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions