Stefan Schüßler
2014-Mar-05 15:36 UTC
Allow hash for conditional class attribute in tag helper
When dealing with conditional class attribute values in HTML tags, I often find myself writing code like: link_to(post.title, post, class: "post #{post.active? ? "active" : ""}") The code would be much cleaner if we allowed a hash syntax: link_to(post.title, post, class: {"post" => true, "active" => post.active?}) The implementation is straightforward: https://github.com/sos4nt/rails/commit/a9ed04f75ce9db46af6cbdefa64dfb09fb3eb73a What do you think? -Stefan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.