I think the class attribute is quite unique because it's a space-separated list. Are there any other attributes like that?
On Wednesday, March 5, 2014 5:04:37 PM UTC+1, Andrew Kaspick wrote: > > -1 > > I don't see why 'class' would get the special treatment when all other > attributes could be candidates too and that style is very inconsistent with > pretty much all of rails and not particularly clear either. > > I personally just use a helper if logic is required for attributes. > > > On Wed, Mar 5, 2014 at 10:36 AM, Stefan Schüßler > <[email protected]<javascript:> > > wrote: > >> 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 [email protected] <javascript:>. >> To post to this group, send email to >> [email protected]<javascript:> >> . >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
