用换行当 class 分隔符?

看了下 Stripe 的官方,class 内的样式用换行分割,可读性很差,是这位开发老哥有才还是我见识少了 laughing

Comments
登录后评论
Sign In
·

这种在 PHP,Ruby 这种语言的代码里很常见吧。

举例: Lobsters 源码里的代码

<li id="story_<%= story.short_id %>" data-shortid="<%= story.short_id %>"
class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
<%= story.vote && story.vote[:vote] == -1 ? "flagged" : "" %>
<%= story.score <= -1 ? "negative_1" : "" %>
<%= story.score <= -3 ? "negative_3" : "" %>
<%= story.score <= -5 ? "negative_5" : "" %>
<%= story.is_hidden_by_cur_user ? "hidden" : "" %>
<%= story.is_saved_by_cur_user ? "saved" : "" %>
<%= story.is_deleted? ? "deleted" : "" %>">

如果不用换行分割,使 class 用空格拼接在一起,代码的可读性会很差。