Skip to content
Sign up for a GitHub account
You can clone with
Did you know you can pass classes into Rails tag helpers as Arrays?
# Let's say you've programatically built up an array of classes for a HTML element:
my_classes = [:a, :b, 'c']
# Don't do this, join(" ") is for chumps:
<% content_tag(:p, "Foo", :class => my_classes.join(" ")) %>
# Winners do this:
<% content_tag(:p, "Foo", :class => my_classes) %>
# => <p class="a b c">Foo</p>
<% link_to("Foo", foos_path, :class => my_classes) %>
# => <a href="/foos" class="a b c">Foo</a>
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
Something went wrong with that request. Please try again.