Sha256: 59a8b6ed776795bb3599f0efce1da8e83d10ba4220d43ede1f581b180d1fce94

Contents?: true

Size: 672 Bytes

Versions: 6

Compression:

Stored size: 672 Bytes

Contents

module Temple
  module CoffeeScript
    class AttributeRemover < Temple::HTML::AttributeRemover
      include Temple::HTML::Dispatcher

      define_options :remove_empty_attrs => %w(id class)

      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
skim-0.11.0 lib/temple/coffee_script/filters/attribute_remover.rb
skim-0.10.0 lib/temple/coffee_script/filters/attribute_remover.rb
skim-0.9.3 lib/temple/coffee_script/filters/attribute_remover.rb
skim-0.9.2 lib/temple/coffee_script/filters/attribute_remover.rb
skim-0.9.1 lib/temple/coffee_script/filters/attribute_remover.rb
skim-0.9.0 lib/temple/coffee_script/filters/attribute_remover.rb