Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Formatter] Inconsistent formatting of multi-line function calls #805

Open
GPla opened this issue Jan 20, 2024 · 0 comments
Open

[BUG] [Formatter] Inconsistent formatting of multi-line function calls #805

GPla opened this issue Jan 20, 2024 · 0 comments
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@GPla
Copy link

GPla commented Jan 20, 2024

System Info

  • OS: Windows 10.0.19045
  • Python Version 3.11.5
  • djLint Version 1.34.1
  • template language: jinja

Issue

There are two problems when splitting a function call inside an expression to multiple lines:

  1. The arguments are indented to the same level as the expression relative to the {{. Strangely, this behavior is affected by comments (maybe other things) above the expression, but this is inconsistent. When this happens, then everything will only be indented to the first level relative to {{.
  2. Calling another function as part of a function call adds a space behind the function and resets the indentation level for arguments below it.

How To Reproduce

Create a issue.html.jinja2 and set indentation to spaces: 2.

{{ render_partial('components/button.html.jinja2',
content='Press me!',
color='forest-green',
icon=render_partial('components/icon.html.jinja2', icon='icon') ,
some_other_arg='my indentation is reset') }}

<div>
  {{ render_partial('components/button.html.jinja2',
    content='Press me!',
    color='forest-green',
    icon=render_partial('components/icon.html.jinja2', icon='icon') ,
  some_other_arg='my indentation is reset') }}
</div>

<div>
  <div>
    {{ render_partial('components/button.html.jinja2',
        content='Press me!',
        color='forest-green',
        icon=render_partial('components/icon.html.jinja2', icon='icon') ,
    some_other_arg='my indentation is reset') }}
  </div>
</div>
@GPla GPla added 🦠 bug Something isn't working 🧽 formatter labels Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦠 bug Something isn't working 🧽 formatter
Projects
None yet
Development

No branches or pull requests

1 participant