edge badge
Methods
C
H
R
S
Constants
ENCODING_TAG = Regexp.new("\\A(<%#{ENCODING_FLAG}-?%>)[ \\t]*")
 
Class Public methods
call(template)
# File actionview/lib/action_view/template/handlers/erb.rb, line 92
def self.call(template)
  new.call(template)
end
Instance Public methods
call(template)
# File actionview/lib/action_view/template/handlers/erb.rb, line 104
def call(template)
  # First, convert to BINARY, so in case the encoding is
  # wrong, we can still find an encoding tag
  # (<%# encoding %>) inside the String using a regular
  # expression
  template_source = template.source.dup.force_encoding(Encoding::ASCII_8BIT)

  erb = template_source.gsub(ENCODING_TAG, '')
  encoding = $2

  erb.force_encoding valid_encoding(template.source.dup, encoding)

  # Always make sure we return a String in the default_internal
  erb.encode!

  self.class.erb_implementation.new(
    erb,
    :escape => (self.class.escape_whitelist.include? template.type),
    :trim => (self.class.erb_trim_mode == "-")
  ).src
end
handles_encoding?()
# File actionview/lib/action_view/template/handlers/erb.rb, line 100
def handles_encoding?
  true
end
resource_cache_call_pattern()

Returns Regexp to extract a cached resource's name from a cache call at the first line of a template. The extracted cache name is captured as :resource_name.

<% cache notification do %> # => notification

The pattern should support templates with a beginning comment:

<%# Still extractable even though there's a comment %>
<% cache notification do %> # => notification

But fail to extract a name if a resource association is cached.

<% cache notification.event do %> # => nil
# File actionview/lib/action_view/template/handlers/erb.rb, line 140
def resource_cache_call_pattern
  /\A
    (?:<%\#.*%>)*                 # optional initial comment
    \s*                           # followed by optional spaces or newlines
    <%\s*cache[\(\s]              # followed by an ERB call to cache
    \s*                           # followed by optional spaces or newlines
    (?<resource_name>\w+)         # capture the cache call argument as :resource_name
    [\s\)]                        # followed by a space or close paren
  /xm
end
supports_streaming?()
# File actionview/lib/action_view/template/handlers/erb.rb, line 96
def supports_streaming?
  true
end