class Haml::Plugin

In Rails 3.1+, template handlers don’t inherit from anything. In <= 3.0, they do. To avoid messy logic figuring this out, we just inherit from whatever the ERB handler does.

Public Class Methods

call(template) click to toggle source

In Rails 3.1+, call takes the place of compile

# File lib/haml/template/plugin.rb, line 38
def self.call(template)
  new.compile(template)
end

Public Instance Methods

cache_fragment(block, name = {}, options = nil) click to toggle source
# File lib/haml/template/plugin.rb, line 42
def cache_fragment(block, name = {}, options = nil)
  @view.fragment_for(block, name, options) do
    eval("_hamlout.buffer", block.binding)
  end
end
compile(template) click to toggle source
# File lib/haml/template/plugin.rb, line 21
def compile(template)
  options = Haml::Template.options.dup

  # template is a template object in Rails >=2.1.0,
  # a source string previously
  if template.respond_to? :source
    # Template has a generic identifier in Rails >=3.0.0
    options[:filename] = template.respond_to?(:identifier) ? template.identifier : template.filename
    source = template.source
  else
    source = template
  end

  Haml::Engine.new(source, options).send(:precompiled_with_ambles, [])
end
handles_encoding?() click to toggle source
# File lib/haml/template/plugin.rb, line 19
def handles_encoding?; true; end