Uneasy conditionals in views?

I have many such conditionals in my views:

  • ...
    > ...

    I am specifically referring to the conditionals in the above code. They
    don’t look very bad. But still, Something is definitely off, this can
    look better. But how?

    would love to hear some comments, how do you guys handle such cases in
    code?

    thanks.
    RoR rocks!!!

  • Jigar G. wrote:

    I have many such conditionals in my views:

  • The ones that control business logic should refactor into the models,
    and the
    ones that control view logic (such as a style= tag) should refactor into
    helpers.

    Next, for larger extents of non-DRY RHTML code, use partials.

    >

    Going in the other direction, feel free to put the <%=%> inside the
    style=’’.
    Then it’s safely empty if it’s nothing.

    Also always follow a perfect “symetry” rule. You don’t break it here,
    but
    abusing partials and <%=%> might lead to that. Always have the < in the
    same
    code region as its >, the same for " and " on both sides of an attribute
    value,
    and balanced tags like

    and
    . Don’t move one of those in a
    partial or
    something if you can help it!

    And test the snot out of your views with assert_select and assert_ypath.
    The
    former gives a coarse but complete view of your HTML, and the latter is
    as
    precise as advanced XPath statements can get.


    Phlip

    And test the snot out of your views with assert_select and assert_ypath.

    Uh, assert_xpath?

    assert_ypath’s time is not yet come! (-: