class ActionView::Template

Action View Template Handlers

Action View Text Template

Action View Template

Constants

Finalizer

Attributes

formats[R]
handler[R]
identifier[R]
original_encoding[R]
source[R]
virtual_path[R]

Public Instance Methods

counter_name() click to toggle source
# File lib/action_view/template.rb, line 154
def counter_name
  @counter_name ||= "#{variable_name}_counter".to_sym
end
inspect() click to toggle source
# File lib/action_view/template.rb, line 158
def inspect
  @inspect ||=
    if defined?(Rails.root)
      identifier.sub("#{Rails.root}/", '')
    else
      identifier
    end
end
mime_type() click to toggle source
# File lib/action_view/template.rb, line 146
def mime_type
  @mime_type ||= Mime::Type.lookup_by_extension(@formats.first.to_s) if @formats.first
end
render(view, locals, &block) click to toggle source
# File lib/action_view/template.rb, line 124
def render(view, locals, &block)
  # Notice that we use a bang in this instrumentation because you don't want to
  # consume this in production. This is only slow if it's being listened to.
  ActiveSupport::Notifications.instrument("!render_template.action_view", :virtual_path => @virtual_path) do
    if view.is_a?(ActionView::CompiledTemplates)
      mod = ActionView::CompiledTemplates
    else
      mod = view.singleton_class
    end

    method_name = compile(locals, view, mod)
    view.send(method_name, locals, &block)
  end
rescue Exception => e
  if e.is_a?(Template::Error)
    e.sub_template_of(self)
    raise e
  else
    raise Template::Error.new(self, view.respond_to?(:assigns) ? view.assigns : {}, e)
  end
end
variable_name() click to toggle source
# File lib/action_view/template.rb, line 150
def variable_name
  @variable_name ||= @virtual_path[%r_?(\w+)(\.\w+)*$', 1].to_sym
end

Public Class Methods

new(source, identifier, handler, details) click to toggle source
# File lib/action_view/template.rb, line 112
def initialize(source, identifier, handler, details)
  @source             = source
  @identifier         = identifier
  @handler            = handler
  @original_encoding  = nil
  @method_names       = {}

  format   = details[:format] || :html
  @formats = Array.wrap(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f }
  @virtual_path = details[:virtual_path].try(:sub, ".#{format}", "")
end