Closed thibaudcolas closed 1 year ago
Thank you for reporting this bug. DjHTML's handling of chained methods is arguably sloppy. This is what happens:
First, the JavaScript is indented "normally" without regards for chained methods:
<script>
window.fetch('/test.html')
.then((html) => {
document.body.innerHTML = html;
});
</script>
Then, any line that starts with a .
is shifted to the right:
<script>
window.fetch('/test.html')
.then((html) => {
document.body.innerHTML = html;
});
</script>
I find it hard to wrap my head around how chained methods could be handled otherwise. However, they definitely should, because the current way introduces all kinds of indentation errors like this.
Thanks again for reporting this bug. I'm happy to inform you DjHTML 3.0.0 has just been released with improved handling of JavaScript method chains, switch/case statements, multi-line variable assignments, and many more JS improvements!
The following JS within HTML:
gets indented as:
I would have expected everything within the script tag to get one extra level of indentation. I’m not sure what is causing this, but I at least tried with both a
function
and the arrow function as above, so I suspect it’s the method chaining that might be the problem.