Method: ActionView::Helpers::TagHelper#class_names

Defined in:
actionview/lib/action_view/helpers/tag_helper.rb

#class_namesObject

Returns a string of tokens built from args.

Examples

token_list("foo", "bar")
 # => "foo bar"
token_list("foo", "foo bar")
 # => "foo bar"
token_list({ foo: true, bar: false })
 # => "foo"
token_list(nil, false, 123, "", "foo", { bar: true })
 # => "123 foo bar"


371
372
373
374
375
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 371

def token_list(*args)
  tokens = build_tag_values(*args).flat_map { |value| CGI.unescape_html(value.to_s).split(/\s+/) }.uniq

  safe_join(tokens, " ")
end