2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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:
|
|
|
|
attr_accessor :type
|
|
|
|
|
|
|
|
def initialize(string, type = nil)
|
|
|
|
@string = string.to_s
|
|
|
|
@type = Types[type] || type if type
|
|
|
|
@type ||= Types[:html]
|
|
|
|
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
|
|
|
|
|
|
|
|
def formats
|
2014-02-18 14:12:51 -05:00
|
|
|
[@type.respond_to?(:ref) ? @type.ref : @type.to_s]
|
2014-02-14 09:57:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|