Class: ActionView::AbstractRenderer

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_view/renderer/abstract_renderer.rb

Overview

:nodoc:

Direct Known Subclasses

PartialRenderer, TemplateRenderer

Instance Method Summary collapse

Constructor Details

#initialize(lookup_context) ⇒ AbstractRenderer



6
7
8
# File 'actionpack/lib/action_view/renderer/abstract_renderer.rb', line 6

def initialize(lookup_context)
  @lookup_context = lookup_context
end

Instance Method Details

#formats_regexpObject



26
27
28
# File 'actionpack/lib/action_view/renderer/abstract_renderer.rb', line 26

def formats_regexp
  @@formats_regexp ||= /\.(#{Mime::SET.symbols.join('|')})$/
end

#renderObject

Raises:

  • (NotImplementedError)


10
11
12
# File 'actionpack/lib/action_view/renderer/abstract_renderer.rb', line 10

def render
  raise NotImplementedError
end

#wrap_formats(value) ⇒ Object

Checks if the given path contains a format and if so, change the lookup context to take this new format into account.



16
17
18
19
20
21
22
23
24
# File 'actionpack/lib/action_view/renderer/abstract_renderer.rb', line 16

def wrap_formats(value)
  return yield unless value.is_a?(String)

  if value.sub!(formats_regexp, "")
    update_details(:formats => [$1.to_sym]){ yield }
  else
    yield
  end
end