djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[BUG] [Formatter] trailing whitespace in jinja macro

Open jayvdb opened this issue 3 months ago • 0 comments

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

jayvdb avatar Sep 14 '25 03:09 jayvdb