class Haml::RailsTemplate

Public Class Methods

options() click to toggle source
# File lib/haml/rails_template.rb, line 11
def options
  @options ||= {
    generator:     Temple::Generators::RailsOutputBuffer,
    use_html_safe: true,
    streaming:     true,
    buffer_class:  'ActionView::OutputBuffer',
    disable_capture: true,
  }
end
set_options(opts) click to toggle source
# File lib/haml/rails_template.rb, line 21
def set_options(opts)
  options.update(opts)
end

Public Instance Methods

call(template, source = nil) click to toggle source
# File lib/haml/rails_template.rb, line 26
def call(template, source = nil)
  source ||= template.source
  options = RailsTemplate.options

  # Make the filename available in parser etc.
  if template.respond_to?(:identifier)
    options = options.merge(filename: template.identifier)
  end

  # https://github.com/haml/haml/blob/4.0.7/lib/haml/template/plugin.rb#L19-L20
  # https://github.com/haml/haml/blob/4.0.7/lib/haml/options.rb#L228
  if template.respond_to?(:type) && template.type == 'text/xml'
    options = options.merge(format: :xhtml)
  end

  if ActionView::Base.try(:annotate_rendered_view_with_filenames) && template.format == :html
    options = options.merge(
      preamble: "<!-- BEGIN #{template.short_identifier} -->\n",
      postamble: "<!-- END #{template.short_identifier} -->\n",
    )
  end

  Engine.new(options).call(source)
end
supports_streaming?() click to toggle source
# File lib/haml/rails_template.rb, line 51
def supports_streaming?
  RailsTemplate.options[:streaming]
end