djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[BUG] [Formatter] Incorrect handling of object context var creates a breaking change

Open rob101 opened this issue 2 years ago • 3 comments

System Info

  • OS: Windows 11
  • Python Version 3.10
  • djLint Version 1.34
  • template language: django-jinja

Issue

In Django, it's common to pass object as a context var. If the object is used in {% set %} djlint will treat it as javascript, creating a breaking change:

This should be untouched:

{% set card_title_1 = object %}

Instead this occurs:

{% set card_title_1 = <class 'object'> %}

How To Reproduce

Run the formatter on any html file containing {% set card_title_1 = object %}

rob101 avatar Nov 06 '23 01:11 rob101

Thanks for opening your first issue here!

welcome[bot] avatar Nov 06 '23 01:11 welcome[bot]

Possibly a regression of https://github.com/Riverside-Healthcare/djLint/issues/756

rob101 avatar Nov 06 '23 01:11 rob101

I have same problem. using it in twig. This is also {{ block('content_artists', input) ?? '' }} reformatted as {{ block('content_artists', <built-in function input>) ?? '' }}

haivala avatar Aug 15 '24 13:08 haivala