Hi,

After doing some React and inspired 
by https://github.com/JedWatson/classnames, what do you think about adding 
a helper method to conditionally join classes.

For example, we have this code in our app to conditionally add classes to a 
div:

<div class="project <%= project.status.active? ? 'active' : '' %> <%= 
project.owner == current_user ?  'owner' : '' %>

<% content_tag(:div, class: "project #{project.status.active? ? 'active' : 
''} #{project.owner == current_user ?  'owner' : ''}"

It will be nice to skip those empty strings with something like this:

<div class="class_names('project', 'active' => project.status.active?, 
'owner' => project.owner == current_user)">

content_tag(:div, class: class_names("project", "active" => 
project.status.active?, "owner" => project.owner == current_user))

Do you think is worth it to put it into Rails?

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to