Multi-line tag attribute alignment
I had some multi-line tags like:
<img src="/some/long/path"
alt="Some text">
DjHTML indented them like so:
<img src="/some/long/path"
alt="Some text">
I think it would be more nautral to retain the “attribute alignment”, and keep alt at the same column as src.
Do you think this would be possible?
Otherwise, the attribue-aligned style I found that works with DjHTML is:
<img
src="/some/long/path"
alt="Some text">
First of all: thanks for noticing!
There are a couple of different ways to indent the contents of multiline HTML tags, or as DjHTML calls it: the wondrous world between "<" and ">".
The current way is as you described, with 1 "indentation unit" (by default 4 spaces) before each line. The main reason is that this was most convenient to implement, because the length of the HTML tag doesn't have to be taken into account:
<img src="/some/long/path"
id="1">
<blockquote class="dishy"
id="2" />
<a href="/some/long/path"
id="3"></a>
Usually when I'm in doubt about The Right Way™ to indent something, I fall back to the implementation of Emacs' web-mode, since that is what I know and love. However, like you, it suggests to indent multiline tags by different amounts, depending on the tag:
<img src="/some/long/path"
id="1">
<blockquote class="dishy"
id="2" />
<a href="/some/long/path"
id="3"></a>
Personally, I think this looks hideous, but that's just my personal taste. It would be awesome if DjHTML supported both styles via a command line flag or even its own config file. I have no plans to work on either of these issues myself, but I will happily accept PRs :hugs:
Finally, both DjHTML and web-mode fall back to 4 spaces when you use your suggested workaround:
<blockquote
class="dishy"
id="2" />
Until this issue is closed that seems to be the best solution.
That would indeed be great feature! Just switched from Prettier and this is the only thing that truly bothers me.
<img src="/some/long/path"
alt="Some text">
Agreed, it would be great feature! Until then, may I suggest to use:
<img
src="/some/long/path"
alt="Some text"
>
I just stumbled over this behaviour and agree with @adamchainz. Maybe this could be stated in the docs? Not sure where to put it, though. I mean, that this happens on purpose and how to fix it.
I'm happy to inform you that multi-line HTML elements are now fully supported in DjHTML 3.0.0, which has just been released. Once again I would like to thank you for contributing and I hope to see you around again!
Glad to see, great work!