Class: Temple::CoffeeScript::AttributeRemover

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

Instance Method Summary collapse

Methods included from Mixins::IndentDispatcher

#on_indent

Instance Method Details

#on_html_attr(name, value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/temple/coffee_script/filters/attribute_remover.rb', line 13

def on_html_attr(name, value)
  if empty_exp?(value)
    value
  elsif contains_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

#on_html_attrs(*attrs) ⇒ Object



8
9
10
11
# File 'lib/temple/coffee_script/filters/attribute_remover.rb', line 8

def on_html_attrs(*attrs)
  [:multi, *(options[:remove_empty_attrs] ?
             attrs.map {|attr| compile(attr) } : attrs)]
end