Module: ViewInspect::ClientSideTemplate

Defined in:
lib/view_inspect/client_side_template.rb

Class Method Summary collapse

Class Method Details

.class_handler_mapObject

only works for sublcasses of Tilt::Template



25
26
27
28
29
30
31
32
33
# File 'lib/view_inspect/client_side_template.rb', line 25

def self.class_handler_map
  hash = {}
  hash[::Ember::Handlebars::Template] = Handlers::Handlebars if defined? ::Ember::Handlebars::Template
  hash[::HandlebarsAssets::TiltHandlebars] = Handlers::Handlebars if defined? ::HandlebarsAssets::TiltHandlebars
  hash[::Sprockets::EjsTemplate]      = Handlers::EJS        if defined? ::Sprockets::EjsTemplate
  hash[::Sprockets::EcoTemplate]      = Handlers::Eco        if defined? ::Sprockets::EcoTemplate
  hash[::Sprockets::JstProcessor]     = Handlers::Jst        if defined? ::Sprockets::JstProcessor
  hash
end

.handleObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/view_inspect/client_side_template.rb', line 10

def self.handle
  class_handler_map.each do |klass, handler|
    klass.class_eval do
      alias_method :orig_initialize, :initialize

      def initialize(file=nil, line=1, options={}, &block)
        orig_initialize(file, line, options, &block)
        handler = ViewInspect::ClientSideTemplate.class_handler_map[self.class]
        @data = handler.new.add_file_line_to_html_tags(@data, file.to_s)
      end
    end
  end
end