Hi Core List
The usual way to conditionally add classes to html tags is in the following
form:
<div class="foo <%= 'ready' if @model.ready? %>"/>
This is hard to read and nod very convenient. ReactJS has an Addon to use a
Hash (Javascript Object) to conditionally add classes
(https://github.com/JedWatson/classnames).
Inspired by this I'd like to add a helper to ActionView which does exactly
that. So you can write:
<div class="<%= class_list 'foo', ready: @model.ready? %>"/>
or
<%= content_tag_for :tr, @model, class: class_list('foo', ready:
@model.ready?) do %>
How do you like this idea? Where should that go? New gem? The newly
extracted content tag gem? Action View Helpers?
Regards
phil
--
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/d/optout.