A Look at the Tumblr Dashboard HTML (Answered)

Oh, look: answers answered me:

Output-markup cleanliness is sacrificed for source-code readability. The source for the above block, with some too-wide Boolean expressions removed for space reasons (don’t worry, they were boring):

<li id="post<?= $post->id ?>"
class="
    post
    <?= $post->type ?>
    <?= (/* [removed for space] */) ? 'same_user_as_last' : '' ?>
    <?= ($post->is_reblog) ? 'is_reblog' : '' ?>
    <?= (/* [removed for space] */) ? 'is_mine' : 'not_mine' ?>
">

Normally I try to enforce an approximate 80-character line-length limit, but

  • this is all David’s code, being front-end, and
  • short length limits are impractical for HTML/view code.

Rest assured the controller and model code looks awesome.

That makes total sense. I’m not sure why I didn’t think about that to begin with. Still, is this considered good/standard PHP coding style? I would definitely think twice if I saw something like this in a Rails app. I think most Rails people would pull all that logic out into a helper:

<li id="post<%= @post.id %>" class="<%= classes_for(@post) %>">
  1. igut reblogged this from do-nothing
  2. interglacial reblogged this from do-nothing
  3. do-nothing reblogged this from dstrelau
  4. takaakik reblogged this from answers
  5. syoichi reblogged this from answers
  6. mix3 reblogged this from tsupo
  7. manamanmana reblogged this from cxx
  8. tsupo reblogged this from cxx
  9. cxx reblogged this from answers
  10. 200 reblogged this from answers and added:
    We have a similar coding style in our Application. I think this case is very difficult, because I wouldn’t mix up Model...
  11. answers reblogged this from dstrelau and added:
    It belongs in the view,...the Post model, because it’s rendering-related. A...
  12. dstrelau reblogged this from answers and added:
    Oh, look: answers answered me:...That makes total sense. I’m not sure why I didn’t think...
  13. peterclark reblogged this from dstrelau
  14. answers reblogged this from dstrelau and added:
    wasn’t. There’s...online generator thing...— it’s compressed...
  15. dstrelau posted this