2010-10-10 05:03:18 -04:00
|
|
|
module ActionView
|
|
|
|
class AbstractRenderer #:nodoc:
|
|
|
|
delegate :find_template, :template_exists?, :with_fallbacks, :update_details,
|
2010-10-16 11:42:19 -04:00
|
|
|
:with_layout_format, :formats, :freeze_formats, :to => :@lookup_context
|
2010-10-10 05:03:18 -04:00
|
|
|
|
2011-05-03 18:12:11 -04:00
|
|
|
def initialize(lookup_context)
|
2011-05-01 04:33:30 -04:00
|
|
|
@lookup_context = lookup_context
|
2010-10-10 05:03:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def render
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2011-09-22 09:03:05 -04:00
|
|
|
protected
|
2010-10-10 05:03:18 -04:00
|
|
|
|
2011-09-22 09:03:05 -04:00
|
|
|
def extract_format(value, details)
|
|
|
|
if value.is_a?(String) && value.sub!(formats_regexp, "")
|
|
|
|
ActiveSupport::Deprecation.warn "Passing the format in the template name is deprecated. " \
|
2011-09-22 09:37:38 -04:00
|
|
|
"Please pass render with :formats => [:#{$1}] instead.", caller
|
2011-09-22 09:03:05 -04:00
|
|
|
details[:formats] ||= [$1.to_sym]
|
2010-10-10 05:03:18 -04:00
|
|
|
end
|
|
|
|
end
|
2010-10-10 06:34:31 -04:00
|
|
|
|
2010-10-16 12:12:41 -04:00
|
|
|
def formats_regexp
|
|
|
|
@@formats_regexp ||= /\.(#{Mime::SET.symbols.join('|')})$/
|
|
|
|
end
|
|
|
|
|
2010-10-10 06:34:31 -04:00
|
|
|
def instrument(name, options={})
|
|
|
|
ActiveSupport::Notifications.instrument("render_#{name}.action_view", options){ yield }
|
|
|
|
end
|
2010-10-10 05:03:18 -04:00
|
|
|
end
|
2010-10-16 11:39:11 -04:00
|
|
|
end
|