2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-02-25 16:18:44 -05:00
|
|
|
require "active_support/deprecation"
|
|
|
|
|
2014-02-14 09:57:47 -05:00
|
|
|
module ActionView #:nodoc:
|
|
|
|
# = Action View HTML Template
|
2017-08-26 20:12:19 -04:00
|
|
|
class Template #:nodoc:
|
2014-02-14 09:57:47 -05:00
|
|
|
class HTML #:nodoc:
|
2019-02-25 16:18:44 -05:00
|
|
|
attr_reader :type
|
2014-02-14 09:57:47 -05:00
|
|
|
|
|
|
|
def initialize(string, type = nil)
|
2019-02-25 16:18:44 -05:00
|
|
|
unless type
|
|
|
|
ActiveSupport::Deprecation.warn "ActionView::Template::HTML#initialize requires a type parameter"
|
|
|
|
type = :html
|
|
|
|
end
|
|
|
|
|
2014-02-14 09:57:47 -05:00
|
|
|
@string = string.to_s
|
2019-02-25 16:18:44 -05:00
|
|
|
@type = type
|
2014-02-14 09:57:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
2016-08-06 12:48:35 -04:00
|
|
|
"html template"
|
2014-02-14 09:57:47 -05:00
|
|
|
end
|
|
|
|
|
2016-09-15 17:11:39 -04:00
|
|
|
alias_method :inspect, :identifier
|
2014-02-14 09:57:47 -05:00
|
|
|
|
|
|
|
def to_str
|
|
|
|
ERB::Util.h(@string)
|
|
|
|
end
|
|
|
|
|
|
|
|
def render(*args)
|
|
|
|
to_str
|
|
|
|
end
|
|
|
|
|
2019-02-25 16:18:44 -05:00
|
|
|
def format
|
|
|
|
@type
|
2014-02-14 09:57:47 -05:00
|
|
|
end
|
2019-02-25 16:18:44 -05:00
|
|
|
|
|
|
|
def formats; Array(format); end
|
|
|
|
deprecate :formats
|
2014-02-14 09:57:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|