Class: Temple::Templates::Rails
Class Method Summary
collapse
Instance Method Summary
collapse
compile, create, register_as
#default_options, #define_deprecated_options, #define_options, #disable_option_validator!, #options, #set_default_options, #set_options
Class Method Details
.register_as(*names) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/temple/templates/rails.rb', line 20
def self.register_as(*names)
raise 'Rails is not loaded - Temple::Templates::Rails cannot be used' unless defined?(::ActionView)
if ::ActiveSupport::VERSION::MAJOR < 5
raise "Temple supports only Rails 5 and greater, your Rails version is #{::ActiveSupport::VERSION::STRING}"
end
names.each do |name|
::ActionView::Template.register_template_handler name.to_sym, new
end
end
|
Instance Method Details
#call(template, source = nil) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/temple/templates/rails.rb', line 7
def call(template, source = nil)
opts = {}.update(self.class.options).update(file: template.identifier)
if ActionView::Base.try(:annotate_rendered_view_with_filenames) && template.format == :html
opts[:preamble] = "<!-- BEGIN #{template.short_identifier} -->\n"
opts[:postamble] = "<!-- END #{template.short_identifier} -->\n"
end
self.class.compile((source || template.source), opts)
end
|
#supports_streaming? ⇒ Boolean
16
17
18
|
# File 'lib/temple/templates/rails.rb', line 16
def supports_streaming?
self.class.options[:streaming]
end
|