diff options
author | Steve Klabnik <steve@steveklabnik.com> | 2012-05-13 20:22:29 -0400 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2012-05-17 12:14:20 -0500 |
commit | 8bea607265a2c9bb9bb2188b0a79089ca373b814 (patch) | |
tree | 61002877ed6a54499d95b957a23e3a5b183cd577 /actionpack/lib/action_view/template | |
parent | 1839ecd2288680dba8533610eb4c9dfe2ab6326e (diff) | |
download | rails-8bea607265a2c9bb9bb2188b0a79089ca373b814.tar.gz rails-8bea607265a2c9bb9bb2188b0a79089ca373b814.tar.bz2 rails-8bea607265a2c9bb9bb2188b0a79089ca373b814.zip |
Created a Raw handler for templates.
Fixes #2394
Diffstat (limited to 'actionpack/lib/action_view/template')
-rw-r--r-- | actionpack/lib/action_view/template/handlers.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/handlers/raw.rb | 11 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/resolver.rb | 4 |
3 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template/handlers.rb b/actionpack/lib/action_view/template/handlers.rb index 4e22bec6cc..41b14373a3 100644 --- a/actionpack/lib/action_view/template/handlers.rb +++ b/actionpack/lib/action_view/template/handlers.rb @@ -4,10 +4,12 @@ module ActionView #:nodoc: module Handlers #:nodoc: autoload :ERB, 'action_view/template/handlers/erb' autoload :Builder, 'action_view/template/handlers/builder' + autoload :Raw, 'action_view/template/handlers/raw' def self.extended(base) base.register_default_template_handler :erb, ERB.new base.register_template_handler :builder, Builder.new + base.register_template_handler :raw, Raw.new end @@template_handlers = {} diff --git a/actionpack/lib/action_view/template/handlers/raw.rb b/actionpack/lib/action_view/template/handlers/raw.rb new file mode 100644 index 0000000000..0c0d1fffcb --- /dev/null +++ b/actionpack/lib/action_view/template/handlers/raw.rb @@ -0,0 +1,11 @@ +module ActionView + module Template::Handlers + class Raw + def call(template) + escaped = template.source.gsub(':', '\:') + + '%q:' + escaped + ':;' + end + end + end +end diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index 08155af013..fa2038f78d 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -171,7 +171,9 @@ module ActionView def extract_handler_and_format(path, default_formats) pieces = File.basename(path).split(".") pieces.shift - handler = Template.handler_for_extension(pieces.pop) + extension = pieces.pop + ActiveSupport::Deprecation.warn "The file #{path} did not specify a template handler. The default is currently ERB, but will change to RAW in the future." unless extension + handler = Template.handler_for_extension(extension) format = pieces.last && Mime[pieces.last] [handler, format] end |