I think its good to have attributes on multiple lines if they're too many, but if you're gonna have it on multiple lines, have all of them on multiple lines for a tag. This is what I would go for.
<some-componentclass="complicated div"[title]="'test'"subtitle="test div"[color]="divColor"><ul><li*ngFor="let item of list"class="list-item"><spani18n>list item</span>
{{item}}
</li></ul></some-component>
If some tag doesn't have that many attributes, maybe let them all be in a single line. If available, I'll definitely use a formatter for this so no one would have to worry about it individually and the styles would be consistent, because we all know if you give devs too much choice they'll spend weeks arguing about each one. Btw, I really like this post series.
Tech enthusiast studying ICT and graduating soon enoughπ¨πΏβπ. Software Engineer in the making, experimenting my way through life. I'm here to connect, learn from y'all and share my knowledge.ππΏ
Coming from Angular, honestly, I'd use brackets to pass data no matter what. This will allow you to pass a variable assigned in your TS file and remove static strings inside of your HTML. (I don't know if this makes sense to you). Otherwise, I agree with @faraazahmad
.
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
I think its good to have attributes on multiple lines if they're too many, but if you're gonna have it on multiple lines, have all of them on multiple lines for a tag. This is what I would go for.
If some tag doesn't have that many attributes, maybe let them all be in a single line. If available, I'll definitely use a formatter for this so no one would have to worry about it individually and the styles would be consistent, because we all know if you give devs too much choice they'll spend weeks arguing about each one. Btw, I really like this post series.
And the difference between
and
I am on board with @faraazahmad 's example.
For properties I'd go with the non-bracketed
subtitle="test"
for simple stringsSame!! π
Coming from Angular, honestly, I'd use brackets to pass data no matter what. This will allow you to pass a variable assigned in your TS file and remove static strings inside of your HTML. (I don't know if this makes sense to you). Otherwise, I agree with @faraazahmad .
Yes forgot to tell, it's an angular example π
I agree with this + using brackets when appropriate.