Open thacoon opened 2 months ago
up, same problem here:
update: i bet it would happen with css also
before:
<script>
{# djlint:off #}
{% if not open_form %}
console.log('my code that should not be formatted')
{% endif %}
{# djlint:on #}
function my_function_that_should_be_indented() {
$("#client_form").show();
$("#list_users").hide();
}
</script>
after:
<script>
{
# djlint: off #
} {
%
if not open_form %
}
console.log('my code that should not be formatted') {
% endif %
} {
# djlint: on #
}
function my_function_that_should_be_indented() {
$("#client_form").show();
$("#list_users").hide();
}
</script>
System Info
Issue
I am sometimes using django templating language inside the script tag. When I reformat the code this gets reformatted as well, so I want to ignore that part using
{# djlint:off #}
. However this is ignored by djlint and it tries to reformat the code resulting in broken javascript code, event{# djlint:off #}
gets reformatted as well. Currently I can only ignore the whole script tag, then nothing gets reformated inside the script tag, but as soon as I only want to ignore a specific part inside it, everything gets reformatted, which then also breaks my JS code.A similar issue was reported, which was fixed in version 1.0.0 #166, however in that previous error the
{# djlint:off #}
comments itself have not been affected, which is now the case.How to Reproduce
I run
djlint --reformat --format-js server/templates/
and get:Contents of .djlintrc/pyproject.toml [tool.djlint]