aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/handlers/erb.rb
diff options
context:
space:
mode:
authorRajinder Yadav <devguy.ca@gmail.com>2010-10-15 22:19:39 -0400
committerRajinder Yadav <devguy.ca@gmail.com>2010-10-15 22:19:39 -0400
commit62eb00a62e3868c3500372def52968b919332b51 (patch)
tree8497f517402c19eae1fea22943565cbf11496ef7 /actionpack/lib/action_view/template/handlers/erb.rb
parent018bf0f5756ef3887815ea46d6671dc1d3b526cf (diff)
parentcffae06a4f1b7aac86a7e99cfb244890f837f976 (diff)
downloadrails-62eb00a62e3868c3500372def52968b919332b51.tar.gz
rails-62eb00a62e3868c3500372def52968b919332b51.tar.bz2
rails-62eb00a62e3868c3500372def52968b919332b51.zip
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'actionpack/lib/action_view/template/handlers/erb.rb')
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index 24e1e44c1d..b827610456 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -1,6 +1,7 @@
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/string/output_safety'
-require "action_view/template"
+require 'action_view/template'
+require 'action_view/template/handler'
require 'erubis'
module ActionView
@@ -47,28 +48,31 @@ module ActionView
end
end
- class ERB < Handler
- include Compilable
-
- ##
- # :singleton-method:
+ class ERB
# Specify trim mode for the ERB compiler. Defaults to '-'.
# See ERb documentation for suitable values.
- cattr_accessor :erb_trim_mode
+ class_attribute :erb_trim_mode
self.erb_trim_mode = '-'
+ # Default format used by ERB.
+ class_attribute :default_format
self.default_format = Mime::HTML
- cattr_accessor :erb_implementation
+ # Default implemenation used.
+ class_attribute :erb_implementation
self.erb_implementation = Erubis
ENCODING_TAG = Regexp.new("\\A(<%#{ENCODING_FLAG}-?%>)[ \\t]*")
- def self.handles_encoding?
+ def self.call(template)
+ new.call(template)
+ end
+
+ def handles_encoding?
true
end
- def compile(template)
+ def call(template)
if template.source.encoding_aware?
# First, convert to BINARY, so in case the encoding is
# wrong, we can still find an encoding tag
@@ -94,6 +98,7 @@ module ActionView
end
private
+
def valid_encoding(string, encoding)
# If a magic encoding comment was found, tag the
# String with this encoding. This is for a case