Class: Temple::CoffeeScript::AttributeRemover

Inherits:
HTML::AttributeRemover
  • Object
show all
Includes:
HTML::Dispatcher
Defined in:
lib/temple/coffee_script/filters/attribute_remover.rb

Instance Method Summary collapse

Instance Method Details

#on_html_attr(name, value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/temple/coffee_script/filters/attribute_remover.rb', line 8

def on_html_attr(name, value)
  return super unless options[:remove_empty_attrs].include?(name.to_s)

  if empty_exp?(value)
    value
  elsif contains_nonempty_static?(value)
    [:html, :attr, name, value]
  else
    tmp = unique_name
    [:multi,
     [:capture, tmp, compile(value)],
     [:if, "#{tmp}.length > 0",
      [:html, :attr, name, [:dynamic, tmp]]]]
  end
end