You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve also encountered an similar issue when trying to format a set function. When trying to format {% set x = print(“Hello”) %}
the result will be
Hello
{% set x = None %}
This behaviour suggests that the code after the equal sign is being executed as Python code, which I belive is unintended behaviour for a linter.
Upon reviewing the code quickly, I suspect that the bug comes from the usage of the eval function here indent.py. However, I’m not sure about purpose of the eval function here.
Maybe someone brighter than me can understand the eval statement?"
for the purpose of formatting nodes that look like JSON5 or lists - it seems later commits might of increased the scope of where this code is executed so that now examples like yours & mine are now evaluated as well; seemingly for formatting functions / function parameters, etc.?
I have found a quick workaround for it, if I use the --no-set-formattingflag it wont try to format the {% set %}. Not a good solution but it doesn't break the code atleast :D
I have found a quick workaround for it, if I use the --no-set-formattingflag it wont try to format the {% set %}. Not a good solution but it doesn't break the code atleast :D
System Info
Issue
If the template shadows a built-in function, such as
dir
, it gets replaced in the template with invalid code that breaks the template.How To Reproduce
Create a template file:
Running
djlint --reformat
produces:As in, the template's contents is now literally:
Which will crash when evaluated.
The text was updated successfully, but these errors were encountered: