Module: ViewInspect::Handlers::Haml

Defined in:
lib/view_inspect/handlers/haml.rb

Class Method Summary collapse

Class Method Details

.augment_sourceObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/view_inspect/handlers/haml.rb', line 5

def self.augment_source
  return unless haml_installed?

  ::Haml::Compiler.class_eval do
    alias_method :orig_compile, :compile

    def compile(node)
      if node.type == :tag
        file_line = [@options[:filename], node.line].join(":")
        node.value[:attributes].merge!(:data => { :orig_file_line => file_line })
      end
      orig_compile(node)
    end
  end
end

.haml_installed?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/view_inspect/handlers/haml.rb', line 21

def self.haml_installed?
  defined? ::Haml::Compiler
end