Module: HamlAssets::HamlSprocketsEngine::ViewContext

Defined in:
lib/haml_assets/haml_sprockets_engine.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_lookup_contextObject

Returns the value of attribute _lookup_context.



22
23
24
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 22

def _lookup_context
  @_lookup_context
end

#_view_rendererObject

Returns the value of attribute _view_renderer.



22
23
24
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 22

def _view_renderer
  @_view_renderer
end

#output_bufferObject

Returns the value of attribute output_buffer.



22
23
24
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 22

def output_buffer
  @output_buffer
end

Class Method Details

.included(klass) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 53

def self.included(klass)
  klass.instance_eval do
    include Rails.application.routes.url_helpers
    include Rails.application.routes.mounted_helpers
    include ActionView::Helpers

    alias_method :output_buffer_without_haml, :output_buffer
    alias_method :output_buffer, :output_buffer_with_haml

    alias_method :set_output_buffer_without_haml, :output_buffer=
    alias_method :output_buffer=, :set_output_buffer_with_haml
  end
end

Instance Method Details

#environment_pathsObject



28
29
30
31
32
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 28

def environment_paths
  paths = environment.paths.to_a
  paths += [(Rails.root + 'app/views').to_s] if HamlAssets::Config.look_in_app_views
  paths
end

#lookup_contextObject



34
35
36
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 34

def lookup_context
  @_lookup_context ||= LookupContext.new(self, environment_paths)
end

#output_buffer_with_hamlObject



38
39
40
41
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 38

def output_buffer_with_haml
  return haml_buffer.buffer if is_haml?
  output_buffer_without_haml
end

#protect_against_forgery?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 67

def protect_against_forgery?
  false
end

#set_output_buffer_with_haml(new) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 43

def set_output_buffer_with_haml(new)
  if is_haml?
    new = String.new(new) if Haml::Util.rails_xss_safe? &&
      new.is_a?(ActiveSupport::SafeBuffer)
    haml_buffer.buffer = new
  else
    set_output_buffer_without_haml new
  end
end

#view_rendererObject



24
25
26
# File 'lib/haml_assets/haml_sprockets_engine.rb', line 24

def view_renderer
  @_view_renderer ||= ActionView::Renderer.new(lookup_context)
end