TagHelper to allows the options of a content_tag to switch based
on a provided condition. This is useful when generating groups of
tags or when needing a tag to react to a current condition, such as
current_controller or a session variable.
content_tag_if(true, :p, 'Hello world!', :class => ['when-true', 'when-false'])
# => <p class="when-true">Hello world!</p>
content_tag_if(false, :p, 'Hello world!', :class => { :if => 'when-true', :else => 'when-false' })
# => <p class="when-false">Hello world!</p>
content_tag_if(current_page?(:controller => 'books'), :p, 'Books', :class => ['current', 'inactive'])
content_tag_if(current_page?(:controller => 'newspapers'), :p, 'Newspapers', :class => ['current', 'inactive'])
# => <p class="current">Books</p><p class="inactive"> Newspapers</p>
ps. This could also be called something like
content_tag_with_binary_options, or
content_tag_with_options_if.