diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2019-04-02 10:10:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 10:10:28 +0200 |
commit | 4525701c90b56aa3c70e08092f06a48187a2ea1d (patch) | |
tree | a3b659e0d833cce45b2d5d6f42306ed6c27ea5db /actionview/lib/action_view/template/raw_file.rb | |
parent | ef5ebd93d68c8287e42754e6bafc6c2ec0afa900 (diff) | |
parent | 90196398a14896e6a279cbbaa6651861360abc0f (diff) | |
download | rails-4525701c90b56aa3c70e08092f06a48187a2ea1d.tar.gz rails-4525701c90b56aa3c70e08092f06a48187a2ea1d.tar.bz2 rails-4525701c90b56aa3c70e08092f06a48187a2ea1d.zip |
Merge pull request #35826 from cpruitt/rename-file-to-rawfile
Rename `Template::File` to `Template::RawFile`
Diffstat (limited to 'actionview/lib/action_view/template/raw_file.rb')
-rw-r--r-- | actionview/lib/action_view/template/raw_file.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/actionview/lib/action_view/template/raw_file.rb b/actionview/lib/action_view/template/raw_file.rb new file mode 100644 index 0000000000..61818ba52f --- /dev/null +++ b/actionview/lib/action_view/template/raw_file.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module ActionView #:nodoc: + # = Action View File Template + class Template #:nodoc: + class RawFile #:nodoc: + attr_accessor :type, :format + + def initialize(filename) + @filename = filename.to_s + extname = ::File.extname(filename).delete(".") + @type = Template::Types[extname] || Template::Types[:text] + @format = @type.symbol + end + + def identifier + @filename + end + + def render(*args) + ::File.read(@filename) + end + + def formats; Array(format); end + deprecate :formats + end + end +end |