Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

tag_options should properly handle arrays

#1741

example:


['tom' => 'admin', 'jim' => 'user'].each_pair do |nick, role|
 <%= content_tag(:span, nick, :class => ["nickname", role]) %>
end

should render


<span class="role admin">tom</span>
<span class="role user">him</span>

instead of:


<span class="roleadmin">tom</span>
<span class="roleuser">him</span>

Everyone who makes lots of complicated views (with proper css classes usage) knows that using interpolation isn't quite handy....

Reported by Tomasz Mazur · January 12th, 2009 @ 10:27 PM

State: resolved
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Tomasz Mazur
    Tomasz Mazur

    fixed example:

    ['tom' => 'admin', 'jim' => 'user'].each_pair do |nick, role| <%= content_tag(:span, nick, :class => ["role", role]) %> end

    January 12th, 2009 @ 11:08 PM

  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag set to bugmash
    • State changed from new to incomplete

    Needs tests

    August 4th, 2009 @ 05:43 PM

  3. Rizwan Reza
    Rizwan Reza
    • Assigned user set to Pratik
    • Tag changed from bugmash to bugmash, verified

    verified.

    +1 The patch attached includes tests. I think this will help creating multiple content tags.

    August 8th, 2009 @ 09:11 PM

  4. Nick Quaranto
    Nick Quaranto
    • Assigned user cleared.
    • Tag changed from bugmash, verified to bugmash

    Added some tests and refactored Tomasz's implementation. You'll have to apply his patch then mine to get this working cleanly.

    August 8th, 2009 @ 10:02 PM

  5. Nick Quaranto
    Nick Quaranto
    • Assigned user set to Pratik
    • Tag changed from bugmash to bugmash, verified

    Looks like Rizwan implemented it as well, sans refactoring. I didn't reload the page to check before, so I'm adding the tags back in.

    August 8th, 2009 @ 10:05 PM

  6. Dan Croak
    Dan Croak

    +1 verified

    tag_options.diff and 0001-Added-tests-for-using-an-Array-in-tag_options-and-re.patch apply cleanly

    and rake test_action_pack runs green on 2-3-stable

    August 8th, 2009 @ 10:10 PM

  7. Josh Nichols
    Josh Nichols
    • Assigned user cleared.

    +1, because I usually end up using :class => "something #{some_variable}" instead of dealing with an array.

    Verified the patches are cool.

    August 8th, 2009 @ 10:11 PM

  8. Nick Quaranto
    Nick Quaranto
    • Assigned user set to Pratik

    Here's a patch that gives credit to Tomasz and is based off master.

    August 8th, 2009 @ 10:12 PM

  9. Rizwan Reza
    Rizwan Reza

    @@ ruby {'tom' => 'admin', 'jim' => 'user'}.each do |nick, role| <%= content_tag(:span, nick, :class => ["nickname", role]) %> end
    @@

    This works well with these patches too. Hash is good too. :)

    August 8th, 2009 @ 10:46 PM

  10. José Valim
    José Valim
    • State changed from incomplete to resolved
    • Tag changed from bugmash, verified to verified

    August 8th, 2009 @ 10:47 PM

  11. Repository
    Repository

    (from [5786395760f1e1906c878df4023cac3741e66e87]) Allow content_tag options to take an array [#1741 tag_options should properly handle arrays state:resolved] [rizwanreza, Nick Quaranto]

    Example:
    content_tag('p', "limelight", :class => ["song", "play"]) # =>

    limelight

    Signed-off-by: Pratik Naik pratiknaik@gmail.com
    http://github.com/rails/rails/commit/5786395760f1e1906c878df4023cac...

    August 9th, 2009 @ 05:12 AM